mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-02 05:19:17 -06:00
27 lines
626 B
JavaScript
27 lines
626 B
JavaScript
'use strict'
|
|
|
|
const validator = require('express-validator').validator
|
|
|
|
const miscValidators = require('./misc')
|
|
|
|
const podsValidators = {
|
|
isEachUniqueHostValid,
|
|
isHostValid
|
|
}
|
|
|
|
function isHostValid (host) {
|
|
return validator.isURL(host) && host.split('://').length === 1
|
|
}
|
|
|
|
function isEachUniqueHostValid (hosts) {
|
|
return miscValidators.isArray(hosts) &&
|
|
hosts.length !== 0 &&
|
|
hosts.every(function (host) {
|
|
return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
|
|
})
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
module.exports = podsValidators
|