blob: ee939ad04b0053722fd281d7ab12a98326ec5066 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import * as validator from 'validator'
import { isArray } from './misc'
function isHostValid (host) {
return validator.isURL(host) && host.split('://').length === 1
}
function isEachUniqueHostValid (hosts) {
return isArray(hosts) &&
hosts.length !== 0 &&
hosts.every(function (host) {
return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
})
}
// ---------------------------------------------------------------------------
export {
isEachUniqueHostValid,
isHostValid
}
|