cljs.util/relative-name still has issues on case-insensitive platforms


cljs.util/relative-name currently works by converting paths to strings and manipulating those. This can cause issues where the strings are identical apart from case: in my case relating to a file from deps.cljs, under Emacs (System/getProperty "user.dir") produces a path with a lower-case drive-letter ("c:\\Users
..."), while the URL argument to relative-name has an upper-case drive-letter, eg "C:\\Users

I believe a more robust approach is to use java.nio.file.Path, which handles paths in a platform-specific way. Patch attached, but happy to take alternative suggestions of course.


Windows (file-system is case-insensitive)
Emacs + Cider, and cmd.exe


Mark Hepburn
November 8, 2017, 10:48 PM

Sorry, finally got back to this. The revised patch adds the pass-through case, and a few tests for case-sensitivity handling on windows.

Oliver George
July 31, 2017, 2:26 AM

A possible corner case for discussion. Test is my own, not in code base at present.

Code currently assumes the file passed is in the path and just plucks off N dirs. No sure if this is guaranteed. Not sure what is best result if it does happen.

  • Could assert to prove it. This has the advantage of providing a nice error for code which violates the assumption.

  • Could pass back original file path in case it's not.

Mark Hepburn
July 14, 2017, 12:33 AM

Renamed according to guidelines, and comment expanded.

Mark Hepburn
July 14, 2017, 12:32 AM

Thanks Francis, I'll admit that did cross my mind and while I thought Java7 was the minimum, I forgot to check.

Thanks David; I've signed the CA and I'll attach the re-formatted patch.





Mark Hepburn