feat: use new URL to check for valid urls instead of a regex

This commit is contained in:
May 2024-11-21 18:31:32 -08:00
parent c57fc48c71
commit 882065381a
Signed by: split
GPG key ID: C325C61F0BF517C0
2 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{
"name": "ava",
"version": "2.0.1",
"version": "2.0.2",
"private": true,
"scripts": {
"dev": "vite dev",

View file

@ -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()