Frontend: Clean valid url code (#12456)

This commit is contained in:
RachelElysia
2023-06-22 08:25:37 -07:00
committed by GitHub
parent acf44e5737
commit 4a6c7f4d8f
2 changed files with 3 additions and 5 deletions
@@ -1,6 +1,7 @@
interface IValidUrl {
url: string;
protocol?: string;
/** Validate protocol specified; http validates both http and https */
protocol?: "http" | "https";
}
export default ({ url, protocol }: IValidUrl): boolean => {
@@ -73,10 +73,7 @@ const Sso = ({
if (!metadataUrl) {
errors.metadata_url = "Metadata or Metadata URL must be present";
errors.metadata = "Metadata or Metadata URL must be present";
} else if (
!validUrl({ url: metadataUrl, protocol: "http" }) &&
!validUrl({ url: metadataUrl, protocol: "https" })
) {
} else if (!validUrl({ url: metadataUrl, protocol: "http" })) {
errors.metadata_url = `${metadataUrl} is not a valid URL`;
}
}