mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-04 04:23:16 -06:00
[feature] Create/update/remove domain permission subscriptions
This commit is contained in:
parent
8504043024
commit
a3743f8234
44 changed files with 4389 additions and 171 deletions
|
|
@ -46,3 +46,22 @@ export function formDomainValidator(domain: string): string {
|
|||
|
||||
return "invalid domain";
|
||||
}
|
||||
|
||||
export function urlValidator(urlStr: string): string {
|
||||
if (urlStr.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let url: URL;
|
||||
try {
|
||||
url = new URL(urlStr);
|
||||
} catch (e) {
|
||||
return e.message;
|
||||
}
|
||||
|
||||
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
||||
return `invalid protocol, must be http or https`;
|
||||
}
|
||||
|
||||
return formDomainValidator(url.host);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue