aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/core-utils.ts9
-rw-r--r--server/helpers/custom-validators/activitypub/misc.ts4
-rw-r--r--server/helpers/custom-validators/servers.ts6
3 files changed, 14 insertions, 5 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 6ebe8e2ac..4bbf0228d 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -165,6 +165,14 @@ function isTestInstance () {
165 return process.env.NODE_ENV === 'test' 165 return process.env.NODE_ENV === 'test'
166} 166}
167 167
168function isDevInstance () {
169 return process.env.NODE_ENV === 'dev'
170}
171
172function isTestOrDevInstance () {
173 return isTestInstance() || isDevInstance()
174}
175
168function isProdInstance () { 176function isProdInstance () {
169 return process.env.NODE_ENV === 'production' 177 return process.env.NODE_ENV === 'production'
170} 178}
@@ -270,6 +278,7 @@ const pipelinePromise = promisify(pipeline)
270 278
271export { 279export {
272 isTestInstance, 280 isTestInstance,
281 isTestOrDevInstance,
273 isProdInstance, 282 isProdInstance,
274 getAppNumber, 283 getAppNumber,
275 284
diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts
index 9d823299f..ff15f115f 100644
--- a/server/helpers/custom-validators/activitypub/misc.ts
+++ b/server/helpers/custom-validators/activitypub/misc.ts
@@ -1,6 +1,6 @@
1import validator from 'validator' 1import validator from 'validator'
2import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' 2import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
3import { isTestInstance } from '../../core-utils' 3import { isTestOrDevInstance } from '../../core-utils'
4import { exists } from '../misc' 4import { exists } from '../misc'
5 5
6function isUrlValid (url: string) { 6function isUrlValid (url: string) {
@@ -13,7 +13,7 @@ function isUrlValid (url: string) {
13 } 13 }
14 14
15 // We validate 'localhost', so we don't have the top level domain 15 // We validate 'localhost', so we don't have the top level domain
16 if (isTestInstance()) { 16 if (isTestOrDevInstance()) {
17 isURLOptions.require_tld = false 17 isURLOptions.require_tld = false
18 } 18 }
19 19
diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts
index c0f8b6aeb..b9f45c282 100644
--- a/server/helpers/custom-validators/servers.ts
+++ b/server/helpers/custom-validators/servers.ts
@@ -1,7 +1,7 @@
1import validator from 'validator' 1import validator from 'validator'
2import { exists, isArray } from './misc'
3import { isTestInstance } from '../core-utils'
4import { CONSTRAINTS_FIELDS } from '../../initializers/constants' 2import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
3import { isTestOrDevInstance } from '../core-utils'
4import { exists, isArray } from './misc'
5 5
6function isHostValid (host: string) { 6function isHostValid (host: string) {
7 const isURLOptions = { 7 const isURLOptions = {
@@ -10,7 +10,7 @@ function isHostValid (host: string) {
10 } 10 }
11 11
12 // We validate 'localhost', so we don't have the top level domain 12 // We validate 'localhost', so we don't have the top level domain
13 if (isTestInstance()) { 13 if (isTestOrDevInstance()) {
14 isURLOptions.require_tld = false 14 isURLOptions.require_tld = false
15 } 15 }
16 16