Skip to content

Commit

Permalink
Fix url validation for context menu (opensearch-project#134)
Browse files Browse the repository at this point in the history
* Fix url validation for context menu

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Fix url validation

Signed-off-by: Joshua Li <joshuali925@gmail.com>
  • Loading branch information
joshuali925 committed Jul 28, 2021
1 parent 7f7124c commit 6918366
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions public/components/context_menu/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
6 changes: 3 additions & 3 deletions public/components/context_menu/context_menu_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 6918366

Please sign in to comment.