mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
First typescript iteration
This commit is contained in:
parent
d5f345ed4c
commit
65fcc3119c
113 changed files with 1961 additions and 1784 deletions
24
server/helpers/custom-validators/pods.ts
Normal file
24
server/helpers/custom-validators/pods.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import expressValidator = require('express-validator')
|
||||
// TODO: use .validator when express-validator typing will have validator field
|
||||
const validator = expressValidator['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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue