Commit c986cde9 authored by thomie's avatar thomie
Browse files

Insert slash when first argument to joinDrive does not end with one

Before:
joinDrive "/foo" "bar" == "/foobar"

After:
joinDrive "/foo" "bar" == "/foo/bar"

The first argument to `joinDrive` should arguably always be a drive. On Posix
this means it should be, and thus end with, a single slash. It is currently
undocumented what should happen when it doesn't end with a slash (throw an
exception?). Since it is unlikely anyone is relying on the original behavior,
this change is hopefully ok to make.

The reason for this change is to make `joinDrive` similar in semantics to
`combineAlways`.
parent facd0dbf
......@@ -383,12 +383,11 @@ readDriveShareName name = addSlash a b
-- > Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo"
-- > Windows: joinDrive "/:" "foo" == "/:\\foo"
joinDrive :: FilePath -> FilePath -> FilePath
joinDrive a b | isPosix = a ++ b
| null a = b
joinDrive a b | null a = b
| null b = a
| hasTrailingPathSeparator a = a ++ b
| otherwise = case a of
[a1,':'] | isLetter a1 -> a ++ b
[a1,':'] | isWindows && isLetter a1 -> a ++ b
_ -> a ++ [pathSeparator] ++ b
-- | Get the drive from a filepath.
......
......@@ -4,6 +4,9 @@
* Bundled with GHC 7.10.1
* Semantic change: `joinDrive "/foo" "bar"` now returns `"/foo/bar"`,
instead of `"/foobar"`.
* 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