]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/pods.js
e38fb341d0fb61c31dccec046dc6a83c97cca285
3 const constants
= require('../initializers/constants')
5 const podsMiddleware
= {
10 function setBodyHostsPort (req
, res
, next
) {
11 for (let i
= 0; i
< req
.body
.hosts
.length
; i
++) {
12 const hostWithPort
= getHostWithPort(req
.body
.hosts
[i
])
14 // Problem with the url parsing?
15 if (hostWithPort
=== null) {
16 return res
.sendStatus(500)
19 req
.body
.hosts
[i
] = hostWithPort
25 function setBodyHostPort (req
, res
, next
) {
26 const hostWithPort
= getHostWithPort(req
.body
.host
)
28 // Problem with the url parsing?
29 if (hostWithPort
=== null) {
30 return res
.sendStatus(500)
33 req
.body
.host
= hostWithPort
38 // ---------------------------------------------------------------------------
40 module
.exports
= podsMiddleware
42 // ---------------------------------------------------------------------------
44 function getHostWithPort (host
) {
45 const splitted
= host
.split(':')
47 // The port was not specified
48 if (splitted
.length
=== 1) {
49 if (constants
.REMOTE_SCHEME
.HTTP
=== 'https') return host
+ ':443'