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(':')
48 // The port was not specified
49 if (splitted.length === 1) {
50 if (constants.REMOTE_SCHEME.HTTP === 'https') return host + ':443'