haskell/filepath — pull request #16 by thomie (2014-10-26 20:29:47+00:00)
Title: Bug fix: equalFilePath "C:\\" "C:" == False

This started out as a simple refactoring of `equalFilePath`, and later turned
out to also fix a small bug.

The refactoring is: use `dropTrailingPathSeparator` instead of the custom
function `dropTrailSlash`.

A difference between these two functions is that `dropTrailingPathSeparator`
potentially removes multiple trailing slashes, whereas `dropTrailSlash` only
removes the last one. But since we `normalise` the FilePath first, which
removes superfluous pathSeparators, this difference does not matter to us.

Another difference is that `dropTrailingPathSeparator` does not drop slashes
when the FilePath isDrive, but `dropTrailSlash` does:

dropTrailSlash "C:\\" == "C:"
dropTrailSlash "C:\\\\" == "C:\\"

dropTrailingPathSeparator "C:\\" == "C:\\"
dropTrailingPathSeparator "C:\\\\" == "C:\\\\"

As a result, equalFilePath of drives on Windows changes slightly:

Before:
equalFilePath "C:\\" "C:" == True
equalFilePath "C:\\\\" "C:" == False

After:
equalFilePath "C:\\" "C:" == False
equalFilePath "C:\\\\" "C:" == False

This can be considered a bug fix, since "C:\\foo" and "C:foo", and thus "C:\\"
and "C:", are not the same thing.