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(); diff --git a/dashboards-reports/server/utils/validationHelper.ts b/dashboards-reports/server/utils/validationHelper.ts index b0aa38fa..705c8cd0 100644 --- a/dashboards-reports/server/utils/validationHelper.ts +++ b/dashboards-reports/server/utils/validationHelper.ts @@ -55,7 +55,7 @@ export const isValidRelativeUrl = (relativeUrl: string) => { export const regexDuration = /^(-?)P(?=\d|T\d)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)([DW]))?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/; export const regexEmailAddress = /\S+@\S+\.\S+/; export const regexReportName = /^[\w\-\s\(\)\[\]\,\_\-+]+$/; -export const regexRelativeUrl = /^\/(_dashboards\/app|app)\/(dashboards|visualize|discover|notebooks-dashboards\?view=output_only)([?&]security_tenant=.+|)#\/(view\/|edit\/)?[^\/]+$/; +export const regexRelativeUrl = /^\/(_plugin\/kibana\/|_dashboards\/)?app\/(dashboards|visualize|discover|notebooks-dashboards\?view=output_only)([?&]security_tenant=.+|)#\/(view\/|edit\/)?[^\/]+$/; export const validateReport = async ( client: ILegacyScopedClusterClient,