Skip to content

Commit

Permalink
fix(OidcModal): avoid using URL.canParse
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhthomas committed Mar 26, 2024
1 parent def0d32 commit 7867509
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/Settings/OidcModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,25 @@ export const oidcSettingsSchema = (intl: IntlShape) => {
.test({
message: 'Issuer URL may not have search parameters.',
test: (val) => {
return !!val && URL.canParse(val) && new URL(val).search === '';
if (!val) return false;
try {
const url = new URL(val);
return url.search === '';
} catch {
return false;
}
},
})
.test({
message: 'Issuer URL protocol must be http / https.',
test: (val) => {
return (
!!val &&
URL.canParse(val) &&
['http:', 'https:'].includes(new URL(val).protocol)
);
if (!val) return false;
try {
const url = new URL(val);
return ['http:', 'https:'].includes(url.protocol);
} catch {
return false;
}
},
}),
clientId: yup.string().required(requiredMessage(messages.oidcClientId)),
Expand Down

0 comments on commit 7867509

Please sign in to comment.