Skip to content
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.

Commit

Permalink
fix: remove references to node globals
Browse files Browse the repository at this point in the history
  • Loading branch information
noramass committed May 17, 2021
1 parent e7897ad commit ff138d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/intercept/intercept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ export function installInterceptors(): void {
interceptFunction(XMLHttpRequest.prototype, "open", xmlHttpRequestOpenMiddleware as any);
interceptFunction(XMLHttpRequest.prototype, "send", xmlHttpRequestSendMiddleware as any, true);
interceptFunction(XMLHttpRequest.prototype, "setRequestHeader", xmlHttpRequestSetRequestHeaderMiddleware as any);
interceptFunction(Function("return this")() as typeof global, "fetch", fetchMiddleware as any);
interceptFunction(Function("return this")() as any, "fetch", fetchMiddleware as any);
}
3 changes: 2 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export function urlMatches(target: string, needle: string): boolean {
return urlAbsolute(target).indexOf(urlAbsolute(needle)) !== -1;
}

export const urlAbsolute = (url: string): string => new URI(url).absoluteTo(global?.location?.href).href();
export const urlAbsolute = (url: string): string =>
new URI(url).absoluteTo(typeof location !== "undefined" ? location?.href : "/").href();

0 comments on commit ff138d1

Please sign in to comment.