file-uri-to-path icon indicating copy to clipboard operation
file-uri-to-path copied to clipboard

"file:" schema not supported, only recognises "file://" (with an empty authority) as a valid file URI

Open jhoag opened this issue 6 years ago • 2 comments

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.

jhoag avatar Apr 13 '18 15:04 jhoag

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.

xmedeko avatar Oct 09 '19 15:10 xmedeko

I see Node.js has a function url.fileURLToPath since v10.12.0.

xmedeko avatar Oct 10 '19 08:10 xmedeko