diff --git a/apps/web/src/app/oauth/oauth-query.test.ts b/apps/web/src/app/oauth/oauth-query.test.ts index c191e308..f3e6b3bd 100644 --- a/apps/web/src/app/oauth/oauth-query.test.ts +++ b/apps/web/src/app/oauth/oauth-query.test.ts @@ -7,9 +7,12 @@ describe("serializeOAuthQuery", () => { serializeOAuthQuery({ client_id: "client", scope: ["lyrashield.read"], + ba_param: ["client_id", "scope", "state"], state: "state", absent: undefined, }) - ).toBe("client_id=client&scope=lyrashield.read&state=state") + ).toBe( + "client_id=client&scope=lyrashield.read&ba_param=client_id&ba_param=scope&ba_param=state&state=state" + ) }) }) diff --git a/apps/web/src/app/oauth/oauth-query.ts b/apps/web/src/app/oauth/oauth-query.ts index 1305074e..26e9f776 100644 --- a/apps/web/src/app/oauth/oauth-query.ts +++ b/apps/web/src/app/oauth/oauth-query.ts @@ -1,7 +1,8 @@ export function serializeOAuthQuery(params: Record) { const query = new URLSearchParams() for (const [key, value] of Object.entries(params)) { - if (value !== undefined) query.set(key, Array.isArray(value) ? (value[0] ?? "") : value) + if (value === undefined) continue + for (const item of Array.isArray(value) ? value : [value]) query.append(key, item) } return query.toString() }