MCPcopy Index your code
hub / github.com/darkreader/darkreader / getAbsoluteURL

Function getAbsoluteURL

src/utils/url.ts:34–46  ·  view source on GitHub ↗
($base: string, $relative: string)

Source from the content-addressed store, hash-verified

32}
33
34export function getAbsoluteURL($base: string, $relative: string): string {
35 if ($relative.match(/^data\\?\:/)) {
36 return $relative;
37 }
38 // Check if relative starts with `//hostname...`.
39 // We have to add a protocol to make it absolute.
40 if (/^\/\//.test($relative)) {
41 return `${location.protocol}${$relative}`;
42 }
43 const b = parseURL($base);
44 const a = parseURL($relative, b.href);
45 return a.href;
46}
47
48// Check if any relative URL is on the window.location;
49// So that https://duck.com/ext.css would return true on https://duck.com/

Callers 5

getURLModifierFunction · 0.90
replaceCSSImportsFunction · 0.90
overrideInlineStyleFunction · 0.90
url.tests.tsFile · 0.90

Calls 1

parseURLFunction · 0.85

Tested by

no test coverage detected