Skip to content

Commit 7018919

Browse files
committed
Replace window with globalThis in browser runtime to support other runtimes as well. Fix #218 #203 #202
1 parent 040b960 commit 7018919

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/runtime/browser/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface IMeta extends IMetaStatic {
1919

2020
const meta: IMetaStatic = {
2121
runtime: "Browser",
22-
browser: window?.["navigator"].userAgent,
22+
browser: globalThis?.["navigator"].userAgent,
2323
};
2424

2525
const pathRegex = /(?:(?:file|https?|global code|[^@]+)@)?(?:file:)?((?:\/[^:/]+){2,})(?::(\d+))?(?::(\d+))?/;
@@ -59,7 +59,7 @@ export function getErrorTrace(error: Error): IStackFrame[] {
5959
}
6060

6161
function stackLineToStackFrame(line?: string): IStackFrame {
62-
const href = window.location.origin;
62+
const href = globalThis.location.origin;
6363
const pathResult: IStackFrame = {
6464
fullFilePath: undefined,
6565
fileName: undefined,

0 commit comments

Comments
 (0)