git.iko.soy/typeable/pandoc
on master help sign in
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.

commit3a291dad3534b6936731b54276b185214a1d6298 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 8 May 2018, 09:54 (8 years ago) parenteb3521e
1 file changed+14
src/Text/Pandoc/Shared.hs+14
src/Text/Pandoc/Shared.hs+14
@@ -84,6 +84,7 @@ module Text.Pandoc.Shared (
8484 -- * File handling
8585 inDirectory,
8686 collapseFilePath,
87+ uriPathToPath,
8788 filteredFilesFromArchive,
8889 -- * URI handling
8990 schemes,
@@ -635,6 +636,19 @@ collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories
635636 isSingleton _ = Nothing
636637 checkPathSeperator = fmap isPathSeparator . isSingleton
637638
639+-- Convert the path part of a file: URI to a regular path.
640+-- On windows, @/c:/foo@ should be @c:/foo@.
641+-- On linux, @/foo@ should be @/foo@.
642+uriPathToPath :: String -> FilePath
643+uriPathToPath path =
644+#ifdef _WINDOWS
645+ case path of
646+ '/':ps -> ps
647+ _ -> p
648+#else
649+ path
650+#endif
651+
638652--
639653-- File selection from the archive
640654--