lib: add UNC support to url.pathToFileURL() · nodejs/node@f29ab40 · GitHub
Skip to content

Commit f29ab40

Browse files
mceachenaddaleax
authored andcommitted
lib: add UNC support to url.pathToFileURL()
Fixes: #34736 PR-URL: #34743 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent b4d9e0d commit f29ab40

3 files changed

Lines changed: 73 additions & 21 deletions

File tree

lib/internal/url.js

Lines changed: 47 additions & 19 deletions

test/parallel/test-url-fileurltopath.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ assert.throws(() => url.fileURLToPath('https://a/b/c'), {
9494
// Euro sign (BMP code point)
9595
{ path: 'C:\\€', fileURL: 'file:///C:/%E2%82%AC' },
9696
// Rocket emoji (non-BMP code point)
97-
{ path: 'C:\\🚀', fileURL: 'file:///C:/%F0%9F%9A%80' }
97+
{ path: 'C:\\🚀', fileURL: 'file:///C:/%F0%9F%9A%80' },
98+
// UNC path (see https://docs.microsoft.com/en-us/archive/blogs/ie/file-uris-in-windows)
99+
{ path: '\\\\nas\\My Docs\\File.doc', fileURL: 'file://nas/My%20Docs/File.doc' },
98100
];
99101
} else {
100102
testCases = [

test/parallel/test-url-pathtofileurl.js

Lines changed: 23 additions & 1 deletion

0 commit comments

Comments
 (0)