vitepress-plugin-filelist 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/browser/index.js +13 -3
- package/package.json +1 -1
|
@@ -428,17 +428,27 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
428
428
|
refresh: false
|
|
429
429
|
}))?.content ?? [];
|
|
430
430
|
}
|
|
431
|
+
function absoluteUrl(raw) {
|
|
432
|
+
if (!raw) return "";
|
|
433
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) return raw;
|
|
434
|
+
const root = baseUrl.value || (typeof window !== "undefined" ? window.location.origin : "");
|
|
435
|
+
try {
|
|
436
|
+
return new URL(raw, `${root}/`).href;
|
|
437
|
+
} catch {
|
|
438
|
+
return raw;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
431
441
|
async function resolveUrl(node) {
|
|
432
442
|
if (demo.value) return "";
|
|
433
|
-
if (node.raw_url) return node.raw_url;
|
|
443
|
+
if (node.raw_url) return absoluteUrl(node.raw_url);
|
|
434
444
|
const cached = downloadCache.get(node.path);
|
|
435
445
|
if (cached) return cached;
|
|
436
446
|
let url = "";
|
|
437
447
|
try {
|
|
438
|
-
url = (await request("/api/fs/get", {
|
|
448
|
+
url = absoluteUrl((await request("/api/fs/get", {
|
|
439
449
|
path: node.path,
|
|
440
450
|
password: node.password || activePassword.value
|
|
441
|
-
}))?.raw_url ?? "";
|
|
451
|
+
}))?.raw_url ?? "");
|
|
442
452
|
} catch {
|
|
443
453
|
url = "";
|
|
444
454
|
}
|
package/package.json
CHANGED