Skip to content

Commit 2d1fb62

Browse files
authored
Fixed Url#getPath to handle empty path with unresolved flag (#1408)
1 parent 3359a50 commit 2d1fb62

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/collection/url.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ _.assign(Url.prototype, /** @lends Url.prototype */ {
285285
getPath (unresolved) {
286286
// for unresolved case, this is super simple as that is how raw data is stored
287287
if (unresolved) {
288-
return PATH_SEPARATOR + this.path.join(PATH_SEPARATOR);
288+
return PATH_SEPARATOR + (
289+
this.path ? this.path.join(PATH_SEPARATOR) : E
290+
);
289291
}
290292

291293
var self = this,

test/unit/url.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,12 @@ describe('Url', function () {
17001700
expect(url.toString()).to.eql('https://postman-echo.com////////get/');
17011701
});
17021702

1703+
it('getPath->unresolved should handle empty path properly', function () {
1704+
var url = new Url('{{host}}');
1705+
1706+
expect(url.getPath(true)).to.be.equal('/');
1707+
});
1708+
17031709
it('should parse string path properly for JSON representation', function () {
17041710
var url = new Url({
17051711
protocol: 'http',

0 commit comments

Comments
 (0)