Skip to content

Commit 5882410

Browse files
test(sonar): fix regex issue
1 parent 72f8c81 commit 5882410

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/api/common/utils.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@ export function getUrlParameters(
2828
if (url === null) {
2929
return null;
3030
}
31-
const regex = /[?&]([^=#]+)=([^&#]*)/g;
32-
const params = {};
33-
let match;
34-
while ((match = regex.exec(url))) {
35-
if (match[1] !== null) {
36-
//@ts-ignore
37-
params[match[1]] = match[2];
38-
}
39-
}
31+
const urlObj = new URL(url);
32+
const params: { [key: string]: string } = {};
33+
urlObj.searchParams.forEach((value, key) => {
34+
params[key] = value;
35+
});
4036
return params;
4137
}
4238

0 commit comments

Comments
 (0)