From 3016b46439811e2ea8dc41fbb87377a2ae09362d Mon Sep 17 00:00:00 2001 From: Rintim Date: Tue, 7 May 2024 00:02:32 +0800 Subject: [PATCH] fix: relative bug. --- noname/get/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/noname/get/index.js b/noname/get/index.js index 1995d160c..8f9f61019 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -4804,6 +4804,10 @@ export class Get { */ relativePath(url, addAssetURL = false) { let base = lib.path.relative(decodeURI(rootURL.pathname), decodeURI(url.pathname)).slice(3); + // 由于`rootURL`的实现,当且仅当url指向`~/noname.js`时,会变为空字符串 + if (base == "") { + base = "noname.js"; + } if (addAssetURL && rootURL.protocol == "file:") { base = `${lib.assetURL}${base}`; }