Skip to content

Commit 31f5e55

Browse files
committed
test: fix tests
1 parent 366ec16 commit 31f5e55

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/lib/utils/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,35 @@ export const parseSearchParamsToObject = (search: string) => {
4242
"state",
4343
"post_login_redirect_url",
4444
"authUrlParams",
45+
"redirect_url"
4546
].includes(key)
4647
) {
4748
delete paramsObject[key];
4849
}
4950
});
5051

52+
53+
Object.keys(paramsObject.authUrlParams).forEach((key) => {
54+
if (
55+
[
56+
"start_page",
57+
"is_create_org",
58+
"response_type",
59+
"org_name",
60+
"org_code",
61+
"state",
62+
"post_login_redirect_url",
63+
"authUrlParams",
64+
"redirect_url"
65+
].includes(key)
66+
) {
67+
delete paramsObject.authUrlParams[key];
68+
}
69+
});
70+
71+
if (Object.keys(paramsObject.authUrlParams).length === 0) {
72+
delete paramsObject.authUrlParams;
73+
}
74+
5175
return paramsObject;
5276
};

src/tests/utils.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ describe("Utils", () => {
66
it("should parse search parameters to an object", () => {
77
const searchParams = "?param1=value1&param2=value2";
88
const expectedOutput = {
9-
param1: "value1",
10-
param2: "value2",
9+
authUrlParams: {
10+
param1: "value1",
11+
param2: "value2",
12+
}
1113
};
1214

1315
const output = parseSearchParamsToObject(searchParams);

0 commit comments

Comments
 (0)