Optimize cdnPath check

This commit is contained in:
Mimi 2020-05-21 10:12:16 +08:00
parent 53c1299b4d
commit 7a2f806695

View File

@ -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", `<div id="waifu">
@ -252,7 +256,7 @@ function loadWidget(config) {
}
}
function initWidget(config, apiPath = "/") {
function initWidget(config, apiPath) {
if (typeof config === "string") {
config = {
waifuPath: config,