feat: ✨ use new URL to check for valid urls instead of a regex
This commit is contained in:
parent
c57fc48c71
commit
882065381a
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ava",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
|
|
@ -30,8 +30,12 @@ export const actions = {
|
|||
|
||||
if (!url || url instanceof File)
|
||||
return fail(400, { error: "no url supplied" })
|
||||
if (url.match(URL_REGEX)?.[0] !== url)
|
||||
|
||||
try {
|
||||
new URL(url)
|
||||
} catch {
|
||||
return fail(400, { error: "bad url" })
|
||||
}
|
||||
|
||||
url = new URL(url).toString()
|
||||
|
||||
|
|
Loading…
Reference in a new issue