[commit: packages/filepath] master: Bug fix: normalise "//home" == "/home" (Posix) (ee25534)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:35:29 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/ee255344c1b071558dba1cced136c8229e6a452a

>---------------------------------------------------------------

commit ee255344c1b071558dba1cced136c8229e6a452a
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Mon Oct 27 18:53:33 2014 +0100

    Bug fix: normalise "//home" == "/home" (Posix)


>---------------------------------------------------------------

ee255344c1b071558dba1cced136c8229e6a452a
 System/FilePath/Internal.hs | 4 +++-
 changelog.md                | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index 5014c48..709751c 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -743,6 +743,7 @@ makeRelative root path
 -- > Posix:   normalise "/./" == "/"
 -- > Posix:   normalise "/" == "/"
 -- > Posix:   normalise "bob/fred/." == "bob/fred/"
+-- > Posix:   normalise "//home" == "/home"
 normalise :: FilePath -> FilePath
 normalise path = result ++ [pathSeparator | addPathSeparator]
     where
@@ -767,7 +768,8 @@ normalise path = result ++ [pathSeparator | addPathSeparator]
         dropDots = filter ("." /=)
 
 normaliseDrive :: FilePath -> FilePath
-normaliseDrive drive | isPosix = drive
+normaliseDrive "" = ""
+normaliseDrive _ | isPosix = [pathSeparator]
 normaliseDrive drive = if isJust $ readDriveLetter x2
                        then map toUpper x2
                        else x2
diff --git a/changelog.md b/changelog.md
index 5fda80a..6e5f2df 100644
--- a/changelog.md
+++ b/changelog.md
@@ -7,6 +7,9 @@
   * Semantic change: `joinDrive "/foo" "bar"` now returns `"/foo/bar"`,
     instead of `"/foobar"`.
 
+  * Bug fix, on Posix systems, `normalise "//home"` now returns `"/home"`,
+    instead of `"//home"`.
+
   * Bug fix, `normalise "/./"` now returns "/" on Posix and "\\" on Windows,
     instead of "//" and "\\\\".
 



More information about the ghc-commits mailing list