Skip to content

Commit

Permalink
Merge pull request #109 from gemini-testing/fix-meta-url
Browse files Browse the repository at this point in the history
fix: Fix url decoration for urls without pathnames
  • Loading branch information
tormozz48 authored Jan 25, 2017
2 parents ae18ebe + 5df188e commit 4a5e654
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports = class Browser {
}

_getMetaUrl(uri) {
return this._config.baseUrl && uri[0] === '/'
return this._config.baseUrl && /^(\/|\?)/.test(uri)
? URI(this._config.baseUrl + uri).normalize().toString()
: uri;
}
Expand Down
12 changes: 11 additions & 1 deletion test/lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('Browser', () => {
});
});

it('should add last url to meta-info', () => {
it('should add last url to meta-info if it starts from /', () => {
return mkBrowser_({baseUrl: 'http://some.domain.org/root'})
.init()
.then((browser) => {
Expand All @@ -228,6 +228,16 @@ describe('Browser', () => {
});
});

it('should add last url to meta-info if it contains only query part', () => {
return mkBrowser_({baseUrl: 'http://some.domain.org/root'})
.init()
.then((browser) => {
session.url('?baz=qux');

assert.equal(browser.meta.url, 'http://some.domain.org/root?baz=qux');
});
});

it('should not concat url without slash at the beginning to the base url', () => {
return mkBrowser_({baseUrl: 'http://some.domain.org'})
.init()
Expand Down

0 comments on commit 4a5e654

Please sign in to comment.