Commit f7869ab0 authored by thomie's avatar thomie
Browse files

Bug fix: normalise "/./" == "/" on Posix, "\\" on Windows

parent 342601f5
......@@ -736,20 +736,25 @@ makeRelative root path
-- > Windows: normalise "c:/file" == "C:\\file"
-- > Windows: normalise "/file" == "\\file"
-- > Windows: normalise "\\" == "\\"
-- > Windows: normalise "/./" == "\\"
-- > normalise "." == "."
-- > Posix: normalise "./" == "./"
-- > Posix: normalise "./." == "./"
-- > Posix: normalise "/./" == "/"
-- > Posix: normalise "/" == "/"
-- > Posix: normalise "bob/fred/." == "bob/fred/"
normalise :: FilePath -> FilePath
normalise path = joinDrive' (normaliseDrive drv) (f pth)
++ [pathSeparator | isDirPath pth && length pth > 1]
normalise path = result ++ [pathSeparator | addPathSeparator]
where
(drv,pth) = splitDrive path
result = joinDrive' (normaliseDrive drv) (f pth)
joinDrive' "" "" = "."
joinDrive' d p = joinDrive d p
addPathSeparator = isDirPath pth
&& not (hasTrailingPathSeparator result)
isDirPath xs = hasTrailingPathSeparator xs
|| not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs)
......
......@@ -7,6 +7,9 @@
* Semantic change: `joinDrive "/foo" "bar"` now returns `"/foo/bar"`,
instead of `"/foobar"`.
* Bug fix, `normalise "/./"` now returns "/" on Posix and "\\" on Windows,
instead of "//" and "\\\\".
* Bug fix: `isDrive ""` now retuns `False`, instead of `True`.
* Bug fix: on Windows, `dropTrailingPathSeparator "/"` now returns `"/"`
......
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