]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/servers.ts
Added translation using Weblate (Latin)
[github/Chocobozzz/PeerTube.git] / server / middlewares / servers.ts
1 import express from 'express'
2 import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
3 import { getHostWithPort } from '../helpers/express-utils'
4
5 function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
6 if (!req.body.hosts) return next()
7
8 for (let i = 0; i < req.body.hosts.length; i++) {
9 const hostWithPort = getHostWithPort(req.body.hosts[i])
10
11 // Problem with the url parsing?
12 if (hostWithPort === null) {
13 return res.fail({
14 status: HttpStatusCode.INTERNAL_SERVER_ERROR_500,
15 message: 'Could not parse hosts'
16 })
17 }
18
19 req.body.hosts[i] = hostWithPort
20 }
21
22 return next()
23 }
24
25 // ---------------------------------------------------------------------------
26
27 export {
28 setBodyHostsPort
29 }