mirror of https://github.com/portainer/portainer
16 lines
263 B
TypeScript
16 lines
263 B
TypeScript
|
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;
|
||
|
}
|
||
|
}
|