From 78675098ab6ee97defe0539bf1a2a46d411b3d43 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Tue, 26 Mar 2024 13:09:22 -0400 Subject: [PATCH] fix(OidcModal): avoid using URL.canParse --- src/components/Settings/OidcModal/index.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/Settings/OidcModal/index.tsx b/src/components/Settings/OidcModal/index.tsx index be58bce83..c135c8c5b 100644 --- a/src/components/Settings/OidcModal/index.tsx +++ b/src/components/Settings/OidcModal/index.tsx @@ -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)),