refactor: change the point of `rootURL`.

This commit is contained in:
Rintim 2024-05-07 00:13:56 +08:00
parent 3016b46439
commit 6226a8ba85
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
2 changed files with 2 additions and 6 deletions

View File

@ -1,4 +1,4 @@
export const rootURL = new URL(import.meta.url);
export const rootURL = new URL("../", import.meta.url);
export { GNC, gnc, setGNC } from "./noname/gnc/index.js";
export { AI, ai, setAI } from "./noname/ai/index.js";

View File

@ -4803,11 +4803,7 @@ export class Get {
* console.log(parsedPath == `${lib.assetURL}noname/get/index.js`) //=> true
*/
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";
}
let base = lib.path.relative(decodeURI(rootURL.pathname), decodeURI(url.pathname));
if (addAssetURL && rootURL.protocol == "file:") {
base = `${lib.assetURL}${base}`;
}