Skip to content

Commit

Permalink
Context URI fix for service workers
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesrosiers committed Feb 4, 2024
1 parent f938a40 commit d8101d4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/browser/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { jrefTypeOf } from "../jref/index.js";


export const get = async (uri, browser = { _cache: {} }) => {
const baseUri = browser.document ? browser.document.baseUri : contextUri();
const baseUri = browser.document?.baseUri ?? contextUri();
uri = resolveIri(uri, baseUri);
const id = toAbsoluteIri(uri);
const { fragment } = parseIri(uri);
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/context-uri.browser.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const contextUri = () => document.location.toString();
export const contextUri = () => document?.location?.toString() ?? "";
3 changes: 2 additions & 1 deletion lib/browser/context-uri.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { cwd } from "node:process";
import { pathToFileURL } from "node:url";


export const contextUri = () => `file://${cwd()}/`;
export const contextUri = () => pathToFileURL(cwd()) + "/";

0 comments on commit d8101d4

Please sign in to comment.