1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00
portainer/app/react/components/form-components/validate-url.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
263 B
TypeScript
Raw Normal View History

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;
}
}