aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Shared.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index a91ca9115..3adf2a1f6 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -129,7 +129,6 @@ import qualified Data.Text as T (toUpper, pack, unpack)
#ifdef EMBED_DATA_FILES
import Text.Pandoc.Data (dataFiles)
-import System.FilePath ( joinPath, splitDirectories )
#else
import Paths_pandoc (getDataFileName)
#endif
@@ -858,15 +857,13 @@ warn msg = do
-- | Remove intermediate "." and ".." directories from a path.
--
--- @
--- collapseFilePath "./foo" == "foo"
--- collapseFilePath "/bar/../baz" == "/baz"
--- collapseFilePath "/../baz" == "/../baz"
--- collapseFilePath "parent/foo/baz/../bar" == "parent/foo/bar"
--- collapseFilePath "parent/foo/baz/../../bar" == "parent/bar"
--- collapseFilePath "parent/foo/.." == "parent"
--- collapseFilePath "/parent/foo/../../bar" == "/bar"
--- @
+-- > collapseFilePath "./foo" == "foo"
+-- > collapseFilePath "/bar/../baz" == "/baz"
+-- > collapseFilePath "/../baz" == "/../baz"
+-- > collapseFilePath "parent/foo/baz/../bar" == "parent/foo/bar"
+-- > collapseFilePath "parent/foo/baz/../../bar" == "parent/bar"
+-- > collapseFilePath "parent/foo/.." == "parent"
+-- > collapseFilePath "/parent/foo/../../bar" == "/bar"
collapseFilePath :: FilePath -> FilePath
collapseFilePath = joinPath . reverse . foldl go [] . splitDirectories
where