Skip to content

Commit

Permalink
add changes from #132 and #134 to fix url validation
Browse files Browse the repository at this point in the history
Signed-off-by: David Cui <davidcui@amazon.com>
  • Loading branch information
davidcui1225 committed Sep 2, 2021
1 parent d0ee90f commit a3a4b3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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
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
2 changes: 1 addition & 1 deletion dashboards-reports/server/utils/validationHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a3a4b3c

Please sign in to comment.