Skip to content

Commit

Permalink
Fix a bug where basepath nextUrl is invalid when it should be valid (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
opensearch-trigger-bot[bot] authored Aug 21, 2024
1 parent e78ba0d commit c3d2b59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions server/utils/next_url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ describe('test validateNextUrl', () => {
expect(validateNextUrl(url, '')).toEqual(undefined);
});

test('allow basePath', () => {
const url = '/osd';
expect(validateNextUrl(url, '/osd')).toEqual(undefined);
});

test('allow dashboard url', () => {
const url =
'/_plugin/opensearch-dashboards/app/opensearch-dashboards#dashbard/dashboard-id?_g=(param=a&p=b)';
Expand Down
2 changes: 1 addition & 1 deletion server/utils/next_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function validateNextUrl(
}
const pathMinusBase = path.replace(bp, '');
if (
!pathMinusBase.startsWith('/') ||
(pathMinusBase && !pathMinusBase.startsWith('/')) ||
(pathMinusBase.length >= 2 && !/^\/[a-zA-Z_][\/a-zA-Z0-9-_]+$/.test(pathMinusBase))
) {
return INVALID_NEXT_URL_PARAMETER_MESSAGE;
Expand Down

0 comments on commit c3d2b59

Please sign in to comment.