fix: slice check
This commit is contained in:
@@ -430,9 +430,14 @@ export class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#getDocDescription() {
|
#getDocDescription() {
|
||||||
|
try {
|
||||||
const meta = document.querySelector('meta[name="description"]');
|
const meta = document.querySelector('meta[name="description"]');
|
||||||
const description = meta ? meta.getAttribute("content") : "";
|
const description = meta ? meta.getAttribute("content") : "";
|
||||||
return description.slice(0, 200);
|
return description.slice(0, 200);
|
||||||
|
} catch (err) {
|
||||||
|
kissLog("get description", err);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监控翻译单元的可见性
|
// 监控翻译单元的可见性
|
||||||
|
|||||||
@@ -198,6 +198,8 @@ export const isSameSet = (a, b) => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const removeEndchar = (s, c, count = 1) => {
|
export const removeEndchar = (s, c, count = 1) => {
|
||||||
|
if (!s) return "";
|
||||||
|
|
||||||
let i = s.length;
|
let i = s.length;
|
||||||
while (i > s.length - count && s[i - 1] === c) {
|
while (i > s.length - count && s[i - 1] === c) {
|
||||||
i--;
|
i--;
|
||||||
|
|||||||
Reference in New Issue
Block a user