Skip to content

Commit

Permalink
Add tests demonstrating incorrect empty relative path serialization b…
Browse files Browse the repository at this point in the history
…y uri.path() and uri.pathname().

Clearly the relative path from"/a/b/c/" to "/a/b/c/" is the empty relative path "", and not "/".

Equivalently, URI("").path() should return the empty string "", but in fact returns "/".

The empty relative path is serialized correctly by .toString(), but incorrectly by .path() and .pathname().
  • Loading branch information
djcsdy committed Apr 23, 2013
1 parent c50b015 commit 8d0c31c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ test("path", function() {
u.pathname('/~userhome/@mine;is %2F and/');
equal(u.pathname(), '/~userhome/@mine;is%20%2F%20and/', "path encoding");
equal(u.pathname(true), '/~userhome/@mine;is %2F and/', "path decoded");

u = new URI('/a/b/c/').relativeTo('/a/b/c/');
equal(u.pathname(), '', "empty relative path");
equal(u.toString(), '', "empty relative path to string");

u.pathname('/');
equal(u.pathname(), '/', "empty absolute path");
equal(u.toString(), '/', "empty absolute path to string");
});
test("query", function() {
var u = new URI("http://example.org/foo.html");
Expand Down

0 comments on commit 8d0c31c

Please sign in to comment.