fix(url validation): correct URL validation for empty fields (#1657)

The isValidURL function was returning false when the provided value was undefined/null/empty, but
needs to return true instead so it doesn't interfere with Yup validation.
This commit is contained in:
Gauthier
2025-05-12 10:18:34 +02:00
committed by GitHub
parent 8da1c92923
commit d226dbb9b4

View File

@@ -1,7 +1,9 @@
export function isValidURL(value: unknown) {
try {
let url: URL;
if (typeof value === 'string') {
if (value === undefined || value === null || value === '') {
return true;
} else if (typeof value === 'string') {
url = new URL(value);
} else if (value instanceof URL) {
url = value;