Skip to content

Commit

Permalink
Avoiding double encoding of query parameter. (#20314)
Browse files Browse the repository at this point in the history
* Avoiding double encoding of `query` parameter.

* Adding test case.
  • Loading branch information
dennisoelkers authored Sep 2, 2024
1 parent 90dfad3 commit d365f46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions graylog2-web-interface/src/util/PaginationURL.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ describe('PaginationUR', () => {

expect(url).toEqual('https://foo/?page=1&per_page=10&bool=false&scope=scope-1&scope=scope-2&query=bar');
});

it('should not URL-encode query parameter twice', () => {
const url = PaginationURL('https://foo', 1, 10, 'my search query');

expect(url).toEqual('https://foo/?page=1&per_page=10&query=my+search+query');
});
});
2 changes: 1 addition & 1 deletion graylog2-web-interface/src/util/PaginationURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default (destUrl: string, page: number, perPage: number, query?: string,
}

if (query) {
uri.addSearch('query', encodeURIComponent(query));
uri.addSearch('query', query);
}

return uri.toString();
Expand Down

0 comments on commit d365f46

Please sign in to comment.