I use node.js URL class to parse different user URLs, no problem with usual protocols and no problem with file: urls under linux.
But I have found a problem with file: under windows when the user tries to specify an absolute path like file://C:\temp\test.jpg
> u = new URL('file://C:\\temp\\test.jpg');
URL {
href: 'file:///C:/temp/test.jpg',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/C:/temp/test.jpg',
search: '',
searchParams: URLSearchParams {},
hash: ''
}
you can see the u.pathname is '/C:/temp/test.jpg', note the leading /, making the pathname useless.
what is the correct way to specify in an URL in nodejs for an absolute path to a windows file?