diff options
author | 2025-01-05 13:20:33 +0100 | |
---|---|---|
committer | 2025-01-05 13:20:33 +0100 | |
commit | e9bb7ddd3aa11da5c48a75c4a600f8fe5cc1c990 (patch) | |
tree | a2897775112a821aa093b6e2686044814912001f /web/source/settings/lib/util/formvalidators.ts | |
parent | [chore] Update robots.txt with more AI bots (#3634) (diff) | |
download | gotosocial-e9bb7ddd3aa11da5c48a75c4a600f8fe5cc1c990.tar.xz |
[feature] Create/update/remove domain permission subscriptions (#3623)
* [feature] Create/update/remove domain permission subscriptions
* lint
* envparsing
* remove errant fmt.Println
* create drafts, subs, exclude, from snapshot models
* name etag column correctly
* remove count column
* lint
Diffstat (limited to 'web/source/settings/lib/util/formvalidators.ts')
-rw-r--r-- | web/source/settings/lib/util/formvalidators.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web/source/settings/lib/util/formvalidators.ts b/web/source/settings/lib/util/formvalidators.ts index c509cf59d..358db616c 100644 --- a/web/source/settings/lib/util/formvalidators.ts +++ b/web/source/settings/lib/util/formvalidators.ts @@ -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); +} |