Moved IsValidURL for Callback URLS to array based (#875)

Co-authored-by: zkldi <20380519+zkldi@users.noreply.github.com>
This commit is contained in:
Fluzzarn
2023-03-21 15:46:21 +00:00
committed by zkldi
co-authored by zkldi
parent 47dca3c8f3
commit 9d9a262e37
2 changed files with 6 additions and 1 deletions
+1
View File
@@ -15,6 +15,7 @@ t.test("#IsValidURL", (t) => {
t.ok(IsValidURL("http://example.com/suburl"));
t.ok(IsValidURL("http://example.com#href"));
t.ok(IsValidURL("http://example.com?querystring"));
t.ok(IsValidURL("tachi-fdsaf7324hf://example.com?querystring"));
t.notOk(IsValidURL("ftp://example.com"));
+5 -1
View File
@@ -127,7 +127,11 @@ export function IsValidURL(string: string) {
try {
const url = new URL(string);
return url.protocol === "http:" || url.protocol === "https:";
return (
url.protocol === "http:" ||
url.protocol === "https:" ||
/^tachi-[a-z0-9]+:$/u.exec(url.protocol)
);
} catch (_err) {
return false;
}