diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-05-08 09:54:19 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-05-08 09:56:42 -0700 |
commit | 3a291dad3534b6936731b54276b185214a1d6298 (patch) | |
tree | 5be0c55db6ebca69859e3752bae21e4fb9b677d2 /src | |
parent | eb3521e4c9ae044f170433d4e30570a0d0578e20 (diff) | |
download | pandoc-3a291dad3534b6936731b54276b185214a1d6298.tar.gz |
Shared: add uriPathToPath.
This adjusts the path from a file: URI in a way that is sensitive
to Windows/Linux differences. Thus, on Windows,
`/c:/foo` gets interpreted as `c:/foo`, but on Linux,
`/c:/foo` gets interpreted as `/c:/foo`.
See #4613.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 8b1af19cd..82ac32980 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -84,6 +84,7 @@ module Text.Pandoc.Shared ( -- * File handling inDirectory, collapseFilePath, + uriPathToPath, filteredFilesFromArchive, -- * URI handling schemes, @@ -635,6 +636,19 @@ collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories isSingleton _ = Nothing checkPathSeperator = fmap isPathSeparator . isSingleton +-- Convert the path part of a file: URI to a regular path. +-- On windows, @/c:/foo@ should be @c:/foo@. +-- On linux, @/foo@ should be @/foo@. +uriPathToPath :: String -> FilePath +uriPathToPath path = +#ifdef _WINDOWS + case path of + '/':ps -> ps + _ -> p +#else + path +#endif + -- -- File selection from the archive -- |