]>
Commit | Line | Data |
---|---|---|
65fcc311 C |
1 | import expressValidator = require('express-validator') |
2 | // TODO: use .validator when express-validator typing will have validator field | |
3 | const validator = expressValidator['validator'] | |
d57d6f26 | 4 | |
65fcc311 | 5 | import { isArray } from './misc' |
67bf9b96 C |
6 | |
7 | function isHostValid (host) { | |
8 | return validator.isURL(host) && host.split('://').length === 1 | |
d57d6f26 C |
9 | } |
10 | ||
49abbbbe | 11 | function isEachUniqueHostValid (hosts) { |
65fcc311 | 12 | return isArray(hosts) && |
49abbbbe C |
13 | hosts.length !== 0 && |
14 | hosts.every(function (host) { | |
67bf9b96 | 15 | return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host) |
d57d6f26 C |
16 | }) |
17 | } | |
18 | ||
19 | // --------------------------------------------------------------------------- | |
20 | ||
65fcc311 C |
21 | export { |
22 | isEachUniqueHostValid, | |
23 | isHostValid | |
24 | } |