refactor: change the point of `rootURL`.
This commit is contained in:
parent
3016b46439
commit
6226a8ba85
|
@ -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 { GNC, gnc, setGNC } from "./noname/gnc/index.js";
|
||||||
export { AI, ai, setAI } from "./noname/ai/index.js";
|
export { AI, ai, setAI } from "./noname/ai/index.js";
|
||||||
|
|
|
@ -4803,11 +4803,7 @@ export class Get {
|
||||||
* console.log(parsedPath == `${lib.assetURL}noname/get/index.js`) //=> true
|
* console.log(parsedPath == `${lib.assetURL}noname/get/index.js`) //=> true
|
||||||
*/
|
*/
|
||||||
relativePath(url, addAssetURL = false) {
|
relativePath(url, addAssetURL = false) {
|
||||||
let base = lib.path.relative(decodeURI(rootURL.pathname), decodeURI(url.pathname)).slice(3);
|
let base = lib.path.relative(decodeURI(rootURL.pathname), decodeURI(url.pathname));
|
||||||
// 由于`rootURL`的实现,当且仅当url指向`~/noname.js`时,会变为空字符串
|
|
||||||
if (base == "") {
|
|
||||||
base = "noname.js";
|
|
||||||
}
|
|
||||||
if (addAssetURL && rootURL.protocol == "file:") {
|
if (addAssetURL && rootURL.protocol == "file:") {
|
||||||
base = `${lib.assetURL}${base}`;
|
base = `${lib.assetURL}${base}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue