Windows: Support urls like "file:///c:/path"
authorJoey Hess <joeyh@joeyh.name>
Mon, 27 Mar 2023 17:38:02 +0000 (13:38 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 27 Mar 2023 17:38:02 +0000 (13:38 -0400)
commitcd076cd085de4525ea07ebe5dfff937e77b902f1
treefef92088d59b913d67a975a5829d0732c264b624
parent3badde71ae0439722af14addfeb93e8309d91f3d
Windows: Support urls like "file:///c:/path"

That is a legal url, but parseUrl parses it to "/c:/path"
which is not a valid path on Windows. So as a workaround, use
parseURIPortable everywhere, which removes the leading slash when
run on windows.

Note that if an url is parsed like this and then serialized back
to a string, it will be different from the input. Which could
potentially be a problem, but is probably not in practice.

An alternative way to do it would be to have an uriPathPortable
that fixes up the path after parsing. But it would be harder to
make sure that is used everywhere, since uriPath is also used
when constructing an URI.

It's also worth noting that System.FilePath.normalize "/c:/path"
yields "c:/path". The reason I didn't use it is that it also
may change "/" to "\" in the path and I wanted to keep the url
changes minimal. Also noticed that convertToWindowsNativeNamespace
handles "/c:/path" the same as "c:/path".

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
Assistant/Restart.hs
Assistant/WebApp/Configurators/WebDAV.hs
CHANGELOG
Command/AddUrl.hs
Command/FromKey.hs
Git/Construct.hs
Git/Credential.hs
Remote/BitTorrent.hs
Remote/External/Types.hs
RemoteDaemon/Types.hs
Utility/Url.hs