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
This commit is contained in:
parent
3badde71ae
commit
cd076cd085
11 changed files with 45 additions and 14 deletions
|
@ -31,6 +31,7 @@ import Logs.Location
|
|||
import Utility.Metered
|
||||
import Utility.HtmlDetect
|
||||
import Utility.Path.Max
|
||||
import Utility.Url (parseURIPortable)
|
||||
import qualified Utility.RawFilePath as R
|
||||
import qualified Annex.Transfer as Transfer
|
||||
|
||||
|
@ -220,7 +221,7 @@ downloadRemoteFile addunlockedmatcher r o uri file sz = checkCanAdd o file $ \ca
|
|||
af = AssociatedFile (Just file)
|
||||
|
||||
startWeb :: AddUnlockedMatcher -> AddUrlOptions -> SeekInput -> URLString -> CommandStart
|
||||
startWeb addunlockedmatcher o si urlstring = go $ fromMaybe bad $ parseURI urlstring
|
||||
startWeb addunlockedmatcher o si urlstring = go $ fromMaybe bad $ parseURIPortable urlstring
|
||||
where
|
||||
bad = fromMaybe (giveup $ "bad url " ++ urlstring) $
|
||||
Url.parseURIRelaxed $ urlstring
|
||||
|
|
|
@ -18,6 +18,7 @@ import Annex.Link
|
|||
import Annex.FileMatcher
|
||||
import Annex.Ingest
|
||||
import Git.FilePath
|
||||
import Utility.Url
|
||||
|
||||
import Network.URI
|
||||
|
||||
|
@ -89,7 +90,7 @@ keyOpt :: String -> Key
|
|||
keyOpt = either giveup id . keyOpt'
|
||||
|
||||
keyOpt' :: String -> Either String Key
|
||||
keyOpt' s = case parseURI s of
|
||||
keyOpt' s = case parseURIPortable s of
|
||||
Just u | not (isKeyPrefix (uriScheme u)) ->
|
||||
Right $ Backend.URL.fromUrl s Nothing
|
||||
_ -> case deserializeKey s of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue