mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 11:58:12 +03:00
Moved IsValidURL for Callback URLS to array based (#875)
Co-authored-by: zkldi <20380519+zkldi@users.noreply.github.com>
This commit is contained in:
committed by
zkldi
co-authored by
zkldi
parent
47dca3c8f3
commit
9d9a262e37
@@ -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"));
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user