| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1530,7 +1530,12 @@ function pathToFileURL(filepath, options = kEmptyObject) { | |||
| 1530 | 1530 | if ((windows ?? isWindows) && StringPrototypeStartsWith(filepath, '\\\\')) { | |
| 1531 | 1531 | const outURL = new URL('file://'); | |
| 1532 | 1532 | // UNC path format: \\server\share\resource | |
| 1533 | - const hostnameEndIndex = StringPrototypeIndexOf(filepath, '\\', 2); | ||
| 1533 | + // Handle extended UNC path and standard UNC path | ||
| 1534 | + // "\\?\UNC\" path prefix should be ignored. | ||
| 1535 | + // Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation | ||
| 1536 | + const isExtendedUNC = StringPrototypeStartsWith(filepath, '\\\\?\\UNC\\'); | ||
| 1537 | + const prefixLength = isExtendedUNC ? 8 : 2; | ||
| 1538 | + const hostnameEndIndex = StringPrototypeIndexOf(filepath, '\\', prefixLength); | ||
| 1534 | 1539 | if (hostnameEndIndex === -1) { | |
| 1535 | 1540 | throw new ERR_INVALID_ARG_VALUE( | |
| 1536 | 1541 | 'path', | |
@@ -1545,7 +1550,7 @@ function pathToFileURL(filepath, options = kEmptyObject) { | |||
| 1545 | 1550 | 'Empty UNC servername', | |
| 1546 | 1551 | ); | |
| 1547 | 1552 | } | |
| 1548 | - const hostname = StringPrototypeSlice(filepath, 2, hostnameEndIndex); | ||
| 1553 | + const hostname = StringPrototypeSlice(filepath, prefixLength, hostnameEndIndex); | ||
| 1549 | 1554 | outURL.hostname = domainToASCII(hostname); | |
| 1550 | 1555 | outURL.pathname = encodePathChars( | |
| 1551 | 1556 | RegExpPrototypeSymbolReplace(backslashRegEx, StringPrototypeSlice(filepath, hostnameEndIndex), '/'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,8 +104,12 @@ const windowsTestCases = [ | |||
| 104 | 104 | { path: 'C:\\€', expected: 'file:///C:/%E2%82%AC' }, | |
| 105 | 105 | // Rocket emoji (non-BMP code point) | |
| 106 | 106 | { path: 'C:\\🚀', expected: 'file:///C:/%F0%9F%9A%80' }, | |
| 107 | + // Local extended path | ||
| 108 | + { path: '\\\\?\\C:\\path\\to\\file.txt', expected: 'file:///C:/path/to/file.txt' }, | ||
| 107 | 109 | // UNC path (see https://docs.microsoft.com/en-us/archive/blogs/ie/file-uris-in-windows) | |
| 108 | 110 | { path: '\\\\nas\\My Docs\\File.doc', expected: 'file://nas/My%20Docs/File.doc' }, | |
| 111 | + // Extended UNC path | ||
| 112 | + { path: '\\\\?\\UNC\\server\\share\\folder\\file.txt', expected: 'file://server/share/folder/file.txt' }, | ||
| 109 | 113 | ]; | |
| 110 | 114 | const posixTestCases = [ | |
| 111 | 115 | // Lowercase ascii alpha | |
| Back | FazBrowse Home | New Git URL |
0 commit comments