svgexport icon indicating copy to clipboard operation
svgexport copied to clipboard

Fix Windows paths by using URL constructor

Open silverwind opened this issue 5 years ago • 0 comments

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.

silverwind avatar Jul 24 '20 13:07 silverwind