Skip to content

Commit

Permalink
Fixing building url with hash mark (#1771)
Browse files Browse the repository at this point in the history
This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after `#`, because client cut everything after `#`
  • Loading branch information
m1neral authored and Khaledgarbaya committed Sep 4, 2018
1 parent 21ae22d commit 81eaa3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

1 comment on commit 81eaa3d

@eduardoflorendo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http client can access internet freedom,protect their data information from possible hacking..

Please sign in to comment.