1 import * as validator from 'validator'
3 import { isArray, exists } from './misc'
4 import { isTestInstance } from '../core-utils'
6 function isHostValid (host: string) {
12 // We validate 'localhost', so we don't have the top level domain
13 if (isTestInstance()) {
14 isURLOptions.require_tld = false
17 return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
20 function isEachUniqueHostValid (hosts: string[]) {
21 return isArray(hosts) &&
24 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
28 // ---------------------------------------------------------------------------
31 isEachUniqueHostValid,
35 declare module 'express-validator' {
36 export interface Validator {