[Dashboard] decode url params, so they are not encoded twice (#54738) (#54776)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Maja Grubic 2020-01-14 20:46:02 +00:00 committed by GitHub
parent 51dccb9555
commit 7038ce28bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -82,10 +82,11 @@ describe('Dashboard URL Helper', () => {
x: 'y',
y: 'z',
});
url = 'http://notDashboardUrl';
expect(getUrlVars(url)).toEqual({});
url = 'http://localhost:5601/app/kibana#/dashboard/777182';
expect(getUrlVars(url)).toEqual({});
url =
'http://localhost:5601/app/kibana#/dashboard/777182?title=Some%20Dashboard%20With%20Spaces';
expect(getUrlVars(url)).toEqual({ title: 'Some Dashboard With Spaces' });
});
it('getLensUrlFromDashboardAbsoluteUrl', () => {

View file

@ -28,7 +28,7 @@ export function getUrlVars(url: string): Record<string, string> {
// @ts-ignore
url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(_, key, value) {
// @ts-ignore
vars[key] = value;
vars[key] = decodeURIComponent(value);
});
return vars;
}