Skip to content

Commit df7360b

Browse files
authored
fix: add script tag validation (#1314)
1 parent 65e8547 commit df7360b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

assets/cjs_shims.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
// if we export it as `const importMetaUrl = ... __filename ...`
44
// But using a function will not cause this issue
55

6-
const getImportMetaUrl = () =>
7-
typeof document === 'undefined'
8-
? new URL(`file:${__filename}`).href
9-
: (document.currentScript && document.currentScript.src) ||
10-
new URL('main.js', document.baseURI).href
6+
const getImportMetaUrl = () =>
7+
typeof document === "undefined"
8+
? new URL(`file:${__filename}`).href
9+
: (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
10+
? document.currentScript.src
11+
: new URL("main.js", document.baseURI).href;
1112

1213
export const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()

0 commit comments

Comments
 (0)