Skip to content

Commit

Permalink
Fix incorrect serialization of empty relative paths.
Browse files Browse the repository at this point in the history
If the URI includes an authority component, then the path is always absolute. Otherwise, the path may be relative and we should not coerce an empty relative path to the empty absolute path.

We check for the presence of a hostname as a proxy for checking for an authority component, because in our implementation the presence of a hostname determines the presence of an authority component.

There was previously a check to see if the URI was a URN, but that is now redundant since a URN cannot include an authority component.
  • Loading branch information
djcsdy committed Apr 23, 2013
1 parent 8d0c31c commit 8049654
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ for (_part in _parts) {

p.pathname = function(v, build) {
if (v === undefined || v === true) {
var res = this._parts.path || (this._parts.urn ? '' : '/');
var res = this._parts.path || (this._parts.hostname ? '/' : '');
return v ? URI.decodePath(res) : res;
} else {
this._parts.path = v ? URI.recodePath(v) : "/";
Expand Down

0 comments on commit 8049654

Please sign in to comment.