Commit 6ab7023f authored by thomie's avatar thomie
Browse files

Bug fix: pathSeparator can be forward slash on Windows

dropTrailingPathSeparator "/" would return "\\" on Windows, since that is the
default:

    pathSeparator = if isWindows then '\\' else '/'

The function `normalise` can be used to normalise pathSeparators in filepaths,
the function `dropTrailingPathSeparator` shouldn't do it for you.

The test now runs for both Posix as Windows.
parent df3f13e7
......@@ -528,14 +528,14 @@ addTrailingPathSeparator x = if hasTrailingPathSeparator x then x else x ++ [pat
-- | Remove any trailing path separators
--
-- > dropTrailingPathSeparator "file/test/" == "file/test"
-- > Posix: dropTrailingPathSeparator "/" == "/"
-- > dropTrailingPathSeparator "/" == "/"
-- > Windows: dropTrailingPathSeparator "\\" == "\\"
-- > Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x
dropTrailingPathSeparator :: FilePath -> FilePath
dropTrailingPathSeparator x =
if hasTrailingPathSeparator x && not (isDrive x)
then let x' = reverse $ dropWhile isPathSeparator $ reverse x
in if null x' then [pathSeparator] else x'
in if null x' then [last x] else x'
else x
......
......@@ -4,6 +4,9 @@
* Bundled with GHC 7.10.1
* Bug fix: on Windows, `dropTrailingPathSeparator "/"` now returns `"/"`
unchanged, instead of the normalised `"\\"`.
## 1.3.0.2 *Mar 2014*
* Bundled with GHC 7.8.1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment