aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/activitypub/misc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/activitypub/misc.ts')
-rw-r--r--server/helpers/custom-validators/activitypub/misc.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts
index f049f5a8c..a94c36b51 100644
--- a/server/helpers/custom-validators/activitypub/misc.ts
+++ b/server/helpers/custom-validators/activitypub/misc.ts
@@ -1,4 +1,7 @@
1import * as validator from 'validator'
1import { exists } from '../misc' 2import { exists } from '../misc'
3import { isTestInstance } from '../../core-utils'
4import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
2 5
3function isActivityPubUrlValid (url: string) { 6function isActivityPubUrlValid (url: string) {
4 const isURLOptions = { 7 const isURLOptions = {
@@ -9,7 +12,12 @@ function isActivityPubUrlValid (url: string) {
9 protocols: [ 'http', 'https' ] 12 protocols: [ 'http', 'https' ]
10 } 13 }
11 14
12 return exists(url) && validator.isURL(url, isURLOptions) 15 // We validate 'localhost', so we don't have the top level domain
16 if (isTestInstance()) {
17 isURLOptions.require_tld = false
18 }
19
20 return exists(url) && validator.isURL(url, isURLOptions) && validator.isLength(url, CONSTRAINTS_FIELDS.ACCOUNTS.URL)
13} 21}
14 22
15function isBaseActivityValid (activity: any, type: string) { 23function isBaseActivityValid (activity: any, type: string) {