From 7a2f8066957553b9f2bdd95429790ec335c33bef Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Thu, 21 May 2020 10:12:16 +0800 Subject: [PATCH] Optimize `cdnPath` check --- waifu-tips.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/waifu-tips.js b/waifu-tips.js index f5abfbf..dab9215 100755 --- a/waifu-tips.js +++ b/waifu-tips.js @@ -9,8 +9,12 @@ function loadWidget(config) { if (typeof cdnPath === "string") { useCDN = true; if (!cdnPath.endsWith("/")) cdnPath += "/"; + } else if (typeof apiPath === "string") { + if (!apiPath.endsWith("/")) apiPath += "/"; + } else { + console.error("Invalid initWidget argument!"); + return; } - if (!apiPath.endsWith("/")) apiPath += "/"; localStorage.removeItem("waifu-display"); sessionStorage.removeItem("waifu-text"); document.body.insertAdjacentHTML("beforeend", `
@@ -252,7 +256,7 @@ function loadWidget(config) { } } -function initWidget(config, apiPath = "/") { +function initWidget(config, apiPath) { if (typeof config === "string") { config = { waifuPath: config,