diff options
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/util.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cli/js/util.ts b/cli/js/util.ts index c50a4cdcb..a67dec595 100644 --- a/cli/js/util.ts +++ b/cli/js/util.ts @@ -82,19 +82,21 @@ export function immutableDefine( } function pathFromURLWin32(url: URL): string { - if (url.hostname !== "") { + const hostname = url.hostname; + const pathname = decodeURIComponent(url.pathname.replace(/\//g, "\\")); + + if (hostname !== "") { //TODO(actual-size) Node adds a punycode decoding step, we should consider adding this - return `\\\\${url.hostname}${url.pathname}`; + return `\\\\${hostname}${pathname}`; } - const validPath = /^\/(?<driveLetter>[A-Za-z]):\//; - const matches = validPath.exec(url.pathname); + const validPath = /^\\(?<driveLetter>[A-Za-z]):\\/; + const matches = validPath.exec(pathname); if (!matches?.groups?.driveLetter) { throw new TypeError("A URL with the file schema must be absolute."); } - const pathname = url.pathname.replace(/\//g, "\\"); // we don't want a leading slash on an absolute path in Windows return pathname.slice(1); } |