3

I tried the following unit tests:

test('nodejs URL pathToFileURL() works', () => {
    let dosPath = '\\\\?\\UNC\\diskstation\\home\\cpan-modules.txt'
    let theUrl = pathToFileURL(dosPath);
    let thePath = fileURLToPath(theUrl);
})
;

And it failed with the following exception:

TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute
    at getPathFromURLWin32 (internal/url.js:1310:13)
    at Object.fileURLToPath (internal/url.js:1342:22)
    at Context.<anonymous> (c:\<anonymized>\out\test\suite\extension.test.js:85:29)
    at processImmediate (internal/timers.js:439:21)

The file exists and can be read:

image showing the command <code>type \\?\UNC\diskstation\home\cpan-modules.txt</code>

Note that the documentation says that pathToFileURL() will make the path absolute. This makes the complaint from fileUrlToPath() about the path not being absolute quite strange.

I am developping a VS-Code extension using VS-Code 1.43.1

image showing VS-Code version

O. Jones
  • 103,626
  • 17
  • 118
  • 172
fjardon
  • 7,921
  • 22
  • 31

0 Answers0