file-uri-to-path
file-uri-to-path copied to clipboard
"file:" schema not supported, only recognises "file://" (with an empty authority) as a valid file URI
The definition of a URI is:
scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
(https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#URL_and_URN)
So the // is optional. At the moment, the validation fails unless the slashes are included.
Expected Any URI starting with "file:" is accepted
Actual URIs are rejected unless they begin"file://"
This is causing issues when using this library in a system with URIs produced by other libraries.
The validation should strip any number of slashes after file:
.
Consider everything after file:
as a path and OS/app may accept any number of slashes at the path start. Even if it's not correct, many apps accept that (e.g. MS Windows), so a user may enter such URI and we want to handle that, too.
I see Node.js has a function url.fileURLToPath
since v10.12.0.