svgexport
svgexport copied to clipboard
Fix Windows paths by using URL constructor
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:
> 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.