Comparing version 1.2.1 to 2.0.0
@@ -9,2 +9,6 @@ # Change Log | ||
## [2.0.0][] | ||
### Changed | ||
- Relative pathnames are respected when merging Url's through `url.mergeFrom()`. If a path starts with a slash, it overwrites the entire path from the merge url. Otherwise it is appended. This affects methods on `oohttp.Base` handling as well. | ||
## [1.1.1][] | ||
@@ -20,4 +24,5 @@ ### Fixed | ||
[Unreleased]: https://github.com/SpectrumBroad/oohttp/compare/v1.1.1...HEAD | ||
[Unreleased]: https://github.com/SpectrumBroad/oohttp/compare/v2.0.0...HEAD | ||
[2.0.0]: https://github.com/SpectrumBroad/oohttp/compare/v1.1.1...v2.0.0 | ||
[1.1.1]: https://github.com/SpectrumBroad/oohttp/compare/v1.1.0...v1.1.1 | ||
[1.1.0]: https://github.com/SpectrumBroad/oohttp/compare/v1.0.0...v1.1.0 |
@@ -213,3 +213,5 @@ 'use strict'; | ||
if (!this.pathname && baseUrl.pathname) { | ||
if (baseUrl.pathname && this.pathname && this.pathname.at(0) !== '/') { | ||
this.pathname = `${baseUrl.pathname}${baseUrl.pathname.at(-1) === '/' ? '' : '/'}${this.pathname}`; | ||
} else if (!this.pathname && baseUrl.pathname) { | ||
this.pathname = baseUrl.pathname; | ||
@@ -280,2 +282,6 @@ } | ||
if (this.pathname) { | ||
if (this.pathname.at(0) !== '/') { | ||
str += '/'; | ||
} | ||
str += this.pathname; | ||
@@ -282,0 +288,0 @@ } |
{ | ||
"name": "oohttp", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "object-oriented http(s) request handler", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -173,2 +173,14 @@ 'use strict'; | ||
}); | ||
it('toString should respect absolute path', function () { | ||
const url = new oohttp.Url('/path/somewhere'); | ||
url.mergeFrom('http://test.test.test/pathname'); | ||
assert.strictEqual('http://test.test.test/path/somewhere', url.toString()); | ||
}); | ||
it('toString should respect relative path', function () { | ||
const url = new oohttp.Url('path/somewhere'); | ||
url.mergeFrom('http://test.test.test/pathname'); | ||
assert.strictEqual('http://test.test.test/pathname/path/somewhere', url.toString()); | ||
}); | ||
}); | ||
@@ -175,0 +187,0 @@ |
47436
1267