1 import * as validator from 'validator'
2 import 'express-validator'
4 import { isArray, exists } from './misc'
5 import { isTestInstance } from '../core-utils'
7 function isHostValid (host: string) {
13 // We validate 'localhost', so we don't have the top level domain
14 if (isTestInstance()) {
15 isURLOptions.require_tld = false
18 return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
21 function isEachUniqueHostValid (hosts: string[]) {
22 return isArray(hosts) &&
25 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
29 // ---------------------------------------------------------------------------
32 isEachUniqueHostValid,