From 9e8f5bb45cf3c83fbf815f2fccdbe08d25d2acae Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 27 Apr 2023 08:51:16 +0200 Subject: [PATCH] added check for undefined (#19949) fixes: #19883 --- .../admin-ui/src/clients/add/LogoutPanel.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/js/apps/admin-ui/src/clients/add/LogoutPanel.tsx b/js/apps/admin-ui/src/clients/add/LogoutPanel.tsx index 5aecbcd688..e911336033 100644 --- a/js/apps/admin-ui/src/clients/add/LogoutPanel.tsx +++ b/js/apps/admin-ui/src/clients/add/LogoutPanel.tsx @@ -11,6 +11,12 @@ import { SaveReset } from "../advanced/SaveReset"; import type { ClientSettingsProps } from "../ClientSettings"; import { FormFields } from "../ClientDetails"; +const validateUrl = (uri: string | undefined, error: string) => + ((uri?.startsWith("https://") || uri?.startsWith("http://")) && + !uri.includes("*")) || + uri === "" || + error; + export const LogoutPanel = ({ save, reset, @@ -92,10 +98,7 @@ export const LogoutPanel = ({ ), { validate: (uri) => - ((uri.startsWith("https://") || uri.startsWith("http://")) && - !uri.includes("*")) || - uri === "" || - t("frontchannelUrlInvalid").toString(), + validateUrl(uri, t("frontchannelUrlInvalid").toString()), } )} validated={ @@ -136,11 +139,7 @@ export const LogoutPanel = ({ ), { validate: (uri) => - ((uri.startsWith("https://") || - uri.startsWith("http://")) && - !uri.includes("*")) || - uri === "" || - t("backchannelUrlInvalid").toString(), + validateUrl(uri, t("backchannelUrlInvalid").toString()), } )} validated={