Commit 00e784d3 authored by thomie's avatar thomie
Browse files

Bug fix: normalise "C:.\\" == "C:"

Another other option would be `normalise "C:.\\" == "C:.\\"`, but this is
nicer since we already have:

> normalise "C:.\\foo"
"C:foo"
parent ee255344
......@@ -731,6 +731,7 @@ makeRelative root path
-- > Posix: normalise "./bob/fred/" == "bob/fred/"
-- > Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\"
-- > Windows: normalise "c:\\" == "C:\\"
-- > Windows: normalise "C:.\\" == "C:"
-- > Windows: normalise "\\\\server\\test" == "\\\\server\\test"
-- > Windows: normalise "//server/test" == "\\\\server\\test"
-- > Windows: normalise "c:/file" == "C:\\file"
......@@ -755,6 +756,7 @@ normalise path = result ++ [pathSeparator | addPathSeparator]
addPathSeparator = isDirPath pth
&& not (hasTrailingPathSeparator result)
&& not (isRelativeDrive drv)
isDirPath xs = hasTrailingPathSeparator xs
|| not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs)
......@@ -868,7 +870,8 @@ makeValid path = joinDrive drv $ validElements $ validChars pth
--
-- * "You cannot use the "\\?\" prefix with a relative path."
isRelative :: FilePath -> Bool
isRelative = isRelativeDrive . takeDrive
isRelative x = null drive || isRelativeDrive drive
where drive = takeDrive x
{- c:foo -}
......@@ -876,7 +879,7 @@ isRelative = isRelativeDrive . takeDrive
-- backslash after the colon, it is interpreted as a relative path to the
-- current directory on the drive with the specified letter."
isRelativeDrive :: String -> Bool
isRelativeDrive x = null x ||
isRelativeDrive x =
maybe False (not . hasTrailingPathSeparator . fst) (readDriveLetter x)
......
......@@ -27,6 +27,9 @@
* Bug fix: on Windows, `normalise "\\"` now retuns `"\\"` unchanged,
instead of `"\\\\"`.
* Bug fix: on Windows, `normalise "C:.\\"` now retuns `"C:"`, instead of
`"C:\\"`.
* Bug fix: on Windows, `normalise "//server/test"` now retuns
`"\\\\server\\test"`, instead of `"//server/test"` unchanged.
......
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