diff options
Diffstat (limited to 'server/helpers/custom-validators/activitypub/misc.ts')
-rw-r--r-- | server/helpers/custom-validators/activitypub/misc.ts | 10 |
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 @@ | |||
1 | import * as validator from 'validator' | ||
1 | import { exists } from '../misc' | 2 | import { exists } from '../misc' |
3 | import { isTestInstance } from '../../core-utils' | ||
4 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | ||
2 | 5 | ||
3 | function isActivityPubUrlValid (url: string) { | 6 | function 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 | ||
15 | function isBaseActivityValid (activity: any, type: string) { | 23 | function isBaseActivityValid (activity: any, type: string) { |