Skip to content

Commit bbe2bbd

Browse files
Fix a bug where basepath nextUrl is invalid when it should be valid (#2096)
* Fix a bug where basepath nextUrl is invalid when it should be valid Signed-off-by: Derek Ho <[email protected]> * Udpate test Signed-off-by: Derek Ho <[email protected]> --------- Signed-off-by: Derek Ho <[email protected]> (cherry picked from commit b1148fb) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e78ba0d commit bbe2bbd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

server/utils/next_url.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ describe('test validateNextUrl', () => {
104104
expect(validateNextUrl(url, '')).toEqual(undefined);
105105
});
106106

107+
test('allow basePath', () => {
108+
const url = '/osd';
109+
expect(validateNextUrl(url, '/osd')).toEqual(undefined);
110+
});
111+
107112
test('allow dashboard url', () => {
108113
const url =
109114
'/_plugin/opensearch-dashboards/app/opensearch-dashboards#dashbard/dashboard-id?_g=(param=a&p=b)';

server/utils/next_url.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function validateNextUrl(
7373
}
7474
const pathMinusBase = path.replace(bp, '');
7575
if (
76-
!pathMinusBase.startsWith('/') ||
76+
(pathMinusBase && !pathMinusBase.startsWith('/')) ||
7777
(pathMinusBase.length >= 2 && !/^\/[a-zA-Z_][\/a-zA-Z0-9-_]+$/.test(pathMinusBase))
7878
) {
7979
return INVALID_NEXT_URL_PARAMETER_MESSAGE;

0 commit comments

Comments
 (0)