Skip to content

Commit aebb30d

Browse files
support if globalThis doesn't exist
1 parent 0c6a45e commit aebb30d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/theme/ReferenceCodeBlock/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ export function parseReference (ref: string): GitHubReference {
2626
/**
2727
* webpack causes failures when it tries to render this page
2828
*/
29-
if (!globalThis.URL) {
29+
const global = globalThis || {}
30+
if (!global.URL) {
3031
// @ts-ignore
31-
globalThis.URL = URL
32+
global.URL = URL
3233
}
3334

34-
const [org, repo, blob, branch, ...pathSeg] = new globalThis.URL(url).pathname.split('/').slice(1)
35+
const [org, repo, blob, branch, ...pathSeg] = new global.URL(url).pathname.split('/').slice(1)
3536
const [fromLine, toLine] = loc
3637
? loc.split('-').map((lineNr) => parseInt(lineNr.slice(1), 10) - 1)
3738
: [0, Infinity]

0 commit comments

Comments
 (0)