You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/form-components/validate-url.ts

16 lines
263 B

export function isValidUrl(
value: string | undefined,
additionalCheck: (url: URL) => boolean = () => true
) {
if (!value) {
return false;
}
try {
const url = new URL(value);
return additionalCheck(url);
} catch {
return false;
}
}