aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/pods.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-15 11:00:25 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit608624252466acf9f1d9ee1c1170bd4fe4d18d18 (patch)
tree47eab55bb5421b7fe88e0b2ac743a436fd9561cf /server/helpers/custom-validators/pods.ts
parent51548b31815c6f96f314ae96588a9adca150519d (diff)
downloadPeerTube-608624252466acf9f1d9ee1c1170bd4fe4d18d18.tar.gz
PeerTube-608624252466acf9f1d9ee1c1170bd4fe4d18d18.tar.zst
PeerTube-608624252466acf9f1d9ee1c1170bd4fe4d18d18.zip
Rename Pod -> Server
Diffstat (limited to 'server/helpers/custom-validators/pods.ts')
-rw-r--r--server/helpers/custom-validators/pods.ts34
1 files changed, 0 insertions, 34 deletions
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts
deleted file mode 100644
index d5021bf38..000000000
--- a/server/helpers/custom-validators/pods.ts
+++ /dev/null
@@ -1,34 +0,0 @@
1import * as validator from 'validator'
2import 'express-validator'
3
4import { isArray, exists } from './misc'
5import { isTestInstance } from '../core-utils'
6
7function isHostValid (host: string) {
8 const isURLOptions = {
9 require_host: true,
10 require_tld: true
11 }
12
13 // We validate 'localhost', so we don't have the top level domain
14 if (isTestInstance()) {
15 isURLOptions.require_tld = false
16 }
17
18 return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
19}
20
21function isEachUniqueHostValid (hosts: string[]) {
22 return isArray(hosts) &&
23 hosts.length !== 0 &&
24 hosts.every(host => {
25 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
26 })
27}
28
29// ---------------------------------------------------------------------------
30
31export {
32 isEachUniqueHostValid,
33 isHostValid
34}