diff options
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index df39f77d8..3adf2a1f6 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -857,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 |