fix(v1): proper Invalid URL handling

This commit is contained in:
Gergo Moricz 2024-09-10 09:24:23 +02:00
parent 2cbc4c59ce
commit 26f2095de6
1 changed files with 8 additions and 1 deletions

View File

@ -30,7 +30,14 @@ export const url = z.preprocess(
"URL must have a valid top-level domain or be a valid path"
)
.refine(
(x) => checkUrl(x as string),
(x) => {
try {
checkUrl(x as string)
return true;
} catch (_) {
return false;
}
},
"Invalid URL"
)
.refine(