Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! url: refactor pathToFileURL to native
  • Loading branch information
aduh95 committed Oct 27, 2024
commit 6ab734f073f358baf5e7b0071331c60486c0b107
17 changes: 11 additions & 6 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,17 @@ class URL {
base = `${base}`;
}

const raiseException = parseSymbol !== kParseURLSymbol;
const interpretAsWindowsPath = parseSymbol === kCreateURLFromWindowsPathSymbol;
const pathToFileURL = interpretAsWindowsPath || (parseSymbol === kCreateURLFromPosixPathSymbol);
const href = pathToFileURL ?
bindingUrl.pathToFileURL(input, interpretAsWindowsPath, base) :
bindingUrl.parse(input, base, raiseException);
let href;
if (arguments.length < 3) {
href = bindingUrl.parse(input, base, true);
} else {
const raiseException = parseSymbol !== kParseURLSymbol;
const interpretAsWindowsPath = parseSymbol === kCreateURLFromWindowsPathSymbol;
const pathToFileURL = interpretAsWindowsPath || (parseSymbol === kCreateURLFromPosixPathSymbol);
href = pathToFileURL ?
bindingUrl.pathToFileURL(input, interpretAsWindowsPath, base) :
bindingUrl.parse(input, base, raiseException);
}
if (href) {
this.#updateContext(href);
}
Expand Down