tlrobinson / narwhal

[DEPRECATED] A JavaScript standard library, package manager, and more.
http://narwhaljs.org/
372 stars 16 forks source link

FILE.relative returns different values depending on trailing slash #47

Open tolmasky opened 15 years ago

tolmasky commented 15 years ago

FILE.relative("a", "a/b/c") => a/b/c FILE.relative("a/", "a/b/c") => b/c (correct)

tlrobinson commented 15 years ago

I think we should match the behavior of other languages here. Here's Ruby's, what are the equivalents in other languages?

>> Pathname("a/b/c").relative_path_from(Pathname("a"))
=> #<Pathname:b/c>
>> Pathname("a/b/c").relative_path_from(Pathname("a/"))
=> #<Pathname:b/c>

http://www.ruby-doc.org/core/classes/Pathname.html#M001722

nevilleburnell commented 15 years ago

added initial tests for file.relative()

http://github.com/cloudwork/narwhal/commit/2d88ca05102bce9cbd55602492d0bd72005cdee7

nevilleburnell commented 15 years ago

moved test cases to commonjs/file/relative.js

http://github.com/cloudwork/narwhal/commit/49a6680c89a27d90637c86153ec9e7b5d3312666