From 55ed98555c11495bdb5650cddfba9e2f602ef80f Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 28 Jul 2021 15:47:24 -0700 Subject: [PATCH] Fix url validation for context menu (#134) * Fix url validation for context menu Signed-off-by: Joshua Li * Fix url validation Signed-off-by: Joshua Li --- .../public/components/context_menu/context_menu.js | 6 +++--- .../public/components/context_menu/context_menu_helpers.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dashboards-reports/public/components/context_menu/context_menu.js b/dashboards-reports/public/components/context_menu/context_menu.js index 52fa76bc..109a3d17 100644 --- a/dashboards-reports/public/components/context_menu/context_menu.js +++ b/dashboards-reports/public/components/context_menu/context_menu.js @@ -66,11 +66,11 @@ const generateInContextReport = async ( } let reportSource = ''; - if (baseUrl.includes('dashboard')) { + if (/\/app\/dashboards/.test(baseUrl)) { reportSource = 'Dashboard'; - } else if (baseUrl.includes('visualize')) { + } else if (/\/app\/visualize/.test(baseUrl)) { reportSource = 'Visualization'; - } else if (baseUrl.includes('discover')) { + } else if (/\/app\/discover/.test(baseUrl)) { reportSource = 'Saved search'; } diff --git a/dashboards-reports/public/components/context_menu/context_menu_helpers.js b/dashboards-reports/public/components/context_menu/context_menu_helpers.js index abd828c7..1c89007b 100644 --- a/dashboards-reports/public/components/context_menu/context_menu_helpers.js +++ b/dashboards-reports/public/components/context_menu/context_menu_helpers.js @@ -71,11 +71,11 @@ export const contextMenuCreateReportDefinition = (baseURI) => { const timeRanges = getTimeFieldsFromUrl(); // check report source - if (baseURI.includes('dashboard')) { + if (/\/app\/dashboards/.test(baseURI)) { reportSource = 'dashboard:'; - } else if (baseURI.includes('visualize')) { + } else if (/\/app\/visualize/.test(baseURI)) { reportSource = 'visualize:'; - } else if (baseURI.includes('discover')) { + } else if (/\/app\/discover/.test(baseURI)) { reportSource = 'discover:'; } reportSource += reportSourceId.toString();