Open silverwind opened 4 years ago
The URL constructor seems to correctly handle both Windows and Unix-style paths so should be the preferred way to generate File-URIs. This does require Node.js 10 or greater where the URL global was introduced.
URL
Some quick tests demonstrating the output:
> String(new URL(`file://c:\\a\\b.svg`)) 'file:///c:/a/b.svg' > String(new URL(`file:///a/b.svg`)) 'file:///a/b.svg'
Can also confirm this works on Windows and Linux.
The URL constructor seems to correctly handle both Windows and Unix-style paths so should be the preferred way to generate File-URIs. This does require Node.js 10 or greater where the
URL
global was introduced.Some quick tests demonstrating the output:
Can also confirm this works on Windows and Linux.