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.
This commit is contained in:
parent
eb3521e4c9
commit
3a291dad35
1 changed files with 14 additions and 0 deletions
|
@ -84,6 +84,7 @@ module Text.Pandoc.Shared (
|
||||||
-- * File handling
|
-- * File handling
|
||||||
inDirectory,
|
inDirectory,
|
||||||
collapseFilePath,
|
collapseFilePath,
|
||||||
|
uriPathToPath,
|
||||||
filteredFilesFromArchive,
|
filteredFilesFromArchive,
|
||||||
-- * URI handling
|
-- * URI handling
|
||||||
schemes,
|
schemes,
|
||||||
|
@ -635,6 +636,19 @@ collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories
|
||||||
isSingleton _ = Nothing
|
isSingleton _ = Nothing
|
||||||
checkPathSeperator = fmap isPathSeparator . isSingleton
|
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
|
-- File selection from the archive
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in a new issue