Skip to content

Commit

Permalink
fixing normalizePath() to properly normalize /.// to / - closes #97
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneyrehm committed Aug 3, 2013
1 parent a2a999a commit bd20c5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ p.normalizePath = function(build) {

// resolve simples
_path = _path
.replace(/(\/(\.\/)+)/g, '/')
.replace(/(\/(\.\/)+)|(\/\.$)/g, '/')
.replace(/\/{2,}/g, '/');

// resolve parents
Expand Down
5 changes: 4 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,10 @@ test("normalizePath", function() {
equal(u.path(), '/foo/bar/baz.html', "URL: dot-relative parent");

u.path('/.//').normalizePath();
equal(u.path(), '/', "root");
equal(u.path(), '/', "root /.//");

u.path('/.').normalizePath();
equal(u.path(), '/', "root /.");

// encoding
u._parts.path = '/~userhome/@mine;is %2F and/';
Expand Down

0 comments on commit bd20c5b

Please sign in to comment.