From 57931b9db2ba4d7a46805c6fbe6c285368970e33 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Thu, 29 Jun 2023 22:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B2=E6=9F=93=E9=97=AE=E9=A2=98bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/editorSvc.js | 4 ++-- src/services/exportSvc.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/editorSvc.js b/src/services/editorSvc.js index e76dbbe6..2de82a14 100644 --- a/src/services/editorSvc.js +++ b/src/services/editorSvc.js @@ -217,8 +217,8 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils, ]; Array.prototype.slice.call(sectionPreviewElt.getElementsByTagName('a')).forEach((aElt) => { - const url = aElt.attributes.href.nodeValue; - if (url.indexOf('http://') >= 0 || url.indexOf('https://') >= 0 || url.indexOf('#') >= 0) { + const url = aElt.attributes && aElt.attributes.href && aElt.attributes.href.nodeValue; + if (!url || url.indexOf('http://') >= 0 || url.indexOf('https://') >= 0 || url.indexOf('#') >= 0) { return; } aElt.href = 'javascript:void(0);'; // eslint-disable-line no-script-url diff --git a/src/services/exportSvc.js b/src/services/exportSvc.js index 800fc6cd..c7ad63cc 100644 --- a/src/services/exportSvc.js +++ b/src/services/exportSvc.js @@ -93,8 +93,8 @@ export default { // 替换相对路径图片为blob图片 const imgs = Array.prototype.slice.call(containerElt.getElementsByTagName('img')).map((imgElt) => { - let uri = imgElt.attributes.src.nodeValue; - if (uri.indexOf('http://') !== 0 && uri.indexOf('https://') !== 0) { + let uri = imgElt.attributes && imgElt.attributes.href && imgElt.attributes.href.nodeValue; + if (uri && uri.indexOf('http://') !== 0 && uri.indexOf('https://') !== 0) { uri = decodeURIComponent(uri); imgElt.removeAttribute('src'); return { imgElt, uri };