Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing building url with hash mark #1771

Merged
merged 1 commit into from Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/helpers/buildURL.js
Expand Up @@ -59,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
}

if (serializedParams) {
var hashmarkIndex = url.indexOf('#');
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}

url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}

Expand Down
6 changes: 6 additions & 0 deletions test/specs/helpers/buildURL.spec.js
Expand Up @@ -54,6 +54,12 @@ describe('helpers::buildURL', function () {
})).toEqual('/foo?query=bar&start=0&length=5');
});

it('should correct discard url hash mark', function () {
expect(buildURL('/foo?foo=bar#hash', {
query: 'baz'
})).toEqual('/foo?foo=bar&query=baz');
});

it('should use serializer if provided', function () {
serializer = sinon.stub();
params = {foo: 'bar'};
Expand Down