mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Rename Pod -> Server
This commit is contained in:
parent
51548b3181
commit
6086242524
77 changed files with 456 additions and 1047 deletions
34
server/helpers/custom-validators/servers.ts
Normal file
34
server/helpers/custom-validators/servers.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import * as validator from 'validator'
|
||||
import 'express-validator'
|
||||
|
||||
import { isArray, exists } from './misc'
|
||||
import { isTestInstance } from '../core-utils'
|
||||
|
||||
function isHostValid (host: string) {
|
||||
const isURLOptions = {
|
||||
require_host: true,
|
||||
require_tld: true
|
||||
}
|
||||
|
||||
// We validate 'localhost', so we don't have the top level domain
|
||||
if (isTestInstance()) {
|
||||
isURLOptions.require_tld = false
|
||||
}
|
||||
|
||||
return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
|
||||
}
|
||||
|
||||
function isEachUniqueHostValid (hosts: string[]) {
|
||||
return isArray(hosts) &&
|
||||
hosts.length !== 0 &&
|
||||
hosts.every(host => {
|
||||
return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
isEachUniqueHostValid,
|
||||
isHostValid
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue