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:
@@ -1,7 +1,9 @@
|
|||||||
export function isValidURL(value: unknown) {
|
export function isValidURL(value: unknown) {
|
||||||
try {
|
try {
|
||||||
let url: URL;
|
let url: URL;
|
||||||
if (typeof value === 'string') {
|
if (value === undefined || value === null || value === '') {
|
||||||
|
return true;
|
||||||
|
} else if (typeof value === 'string') {
|
||||||
url = new URL(value);
|
url = new URL(value);
|
||||||
} else if (value instanceof URL) {
|
} else if (value instanceof URL) {
|
||||||
url = value;
|
url = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user