Comparing version 0.0.4 to 0.0.5
@@ -108,3 +108,6 @@ var nodeUrl = require('url'); | ||
var pieces = this.path().split("/"); | ||
pieces.pop(); | ||
var popped = pieces.pop(); | ||
if (popped === ''){ // ignore trailing slash | ||
pieces.pop(); | ||
} | ||
return this.path(pieces.join("/")); | ||
@@ -119,3 +122,10 @@ }; | ||
// if no suffix, return the child | ||
return _.last(this.path().split("/")); | ||
var pieces = this.path().split("/"); | ||
var last = _.last(pieces); | ||
if ((pieces.length > 1) && (last === '')){ | ||
// ignore trailing slashes | ||
pieces.pop(); | ||
last = _.last(pieces); | ||
} | ||
return last; | ||
} | ||
@@ -122,0 +132,0 @@ }; |
@@ -5,3 +5,3 @@ { | ||
"keywords" : ["url", "uri"], | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"bugs": { | ||
@@ -8,0 +8,0 @@ "url": "https://github.com/cainus/urlgrey/issues" |
@@ -118,2 +118,7 @@ var should = require('should'); | ||
}); | ||
it("ignores a trailing slash", function(){ | ||
var url = "http://asdf.com/path/kid/?asdf=1234#frag"; | ||
urlgrey(url).parent() | ||
.toString().should.equal('http://asdf.com/path?asdf=1234#frag'); | ||
}); | ||
}); | ||
@@ -130,2 +135,6 @@ describe("#child", function(){ | ||
}); | ||
it("ignores a trailing slash", function(){ | ||
var url = "http://asdf.com/path/kid/?asdf=1234#frag"; | ||
urlgrey(url).child().should.equal('kid'); | ||
}); | ||
}); | ||
@@ -132,0 +141,0 @@ describe("#toString", function(){ |
30069
415