Skip to content

Commit 7894f87

Browse files
committed
Address code review feedback - use URLSearchParams and fix error types
1 parent e16b198 commit 7894f87

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/app/modules/spcp/spcp.oidc.client.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,24 @@ export class CpOidcClient extends SpcpOidcBaseClient {
605605
baseClient.issuer.metadata.authorization_endpoint
606606

607607
if (!authorizationEndpoint) {
608-
throw new CreateParRequestError(
608+
throw new CreateAuthorisationUrlError(
609609
'Authorization endpoint not found in issuer metadata',
610610
)
611611
}
612612

613-
const authorisationUrl = `${authorizationEndpoint}?client_id=${encodeURIComponent(this.rpClientId)}&request_uri=${encodeURIComponent(data.request_uri)}`
613+
const authorisationUrlParams = new URLSearchParams({
614+
client_id: this.rpClientId,
615+
request_uri: data.request_uri,
616+
})
617+
618+
const authorisationUrl = `${authorizationEndpoint}?${authorisationUrlParams.toString()}`
614619

615620
return authorisationUrl
616621
} catch (err) {
617-
if (err instanceof CreateParRequestError) {
622+
if (
623+
err instanceof CreateParRequestError ||
624+
err instanceof CreateAuthorisationUrlError
625+
) {
618626
throw err
619627
}
620628
throw new CreateParRequestError(

0 commit comments

Comments
 (0)