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