Skip to content

Commit 0400f86

Browse files
committed
location is not available in Node.js environment
Fixes #218
1 parent c939089 commit 0400f86

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

websocket/findMetadata.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ export const findMetadata = (
6161

6262
const fileUrlPattern = new RegExp(
6363
`${
64-
location?.origin ?? "https://scrapbox.io"
65-
}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$`,
64+
// For Node compatibility, we need to access `location` via `globalThis`
65+
// deno-lint-ignore no-explicit-any
66+
(globalThis as any).location?.origin ??
67+
"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$`,
6668
);
6769

6870
const lookup = (node: Node) => {

0 commit comments

Comments
 (0)