From 7ca858ee8dc51ad37fd085e2c9ff291aa6cf534a Mon Sep 17 00:00:00 2001 From: Maja Grubic Date: Wed, 15 Jan 2020 14:02:46 +0000 Subject: [PATCH] [Dashboard][Lens] Small code fixes (#54625) Co-authored-by: Elastic Machine --- .../kibana/public/dashboard/np_ready/url_helper.ts | 6 ++---- x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/url_helper.ts b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/url_helper.ts index 2e360567c4653..73383f2ff3f68 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/url_helper.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/url_helper.ts @@ -25,11 +25,9 @@ import { DashboardConstants } from './dashboard_constants'; */ export function getUrlVars(url: string): Record { const vars: Record = {}; - // @ts-ignore - url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(_, key, value) { - // @ts-ignore + for (const [, key, value] of url.matchAll(/[?&]+([^=&]+)=([^&]*)/gi)) { vars[key] = decodeURIComponent(value); - }); + } return vars; } diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx index 7465de2dba7f1..f7d9ae5741afb 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx @@ -103,13 +103,13 @@ export class AppPlugin { }) ); const updateUrlTime = (urlVars: Record): void => { - const decoded: RisonObject = rison.decode(urlVars._g) as RisonObject; - if (!decoded) { + const decoded = rison.decode(urlVars._g); + if (!isRisonObject(decoded)) { return; } // @ts-ignore decoded.time = data.query.timefilter.timefilter.getTime(); - urlVars._g = rison.encode((decoded as unknown) as RisonObject); + urlVars._g = rison.encode(decoded); }; const redirectTo = ( routeProps: RouteComponentProps<{ id?: string }>,