aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/pods.js')
-rw-r--r--server/middlewares/pods.js59
1 files changed, 0 insertions, 59 deletions
diff --git a/server/middlewares/pods.js b/server/middlewares/pods.js
deleted file mode 100644
index 2647f9ff0..000000000
--- a/server/middlewares/pods.js
+++ /dev/null
@@ -1,59 +0,0 @@
1'use strict'
2
3const constants = require('../initializers/constants')
4
5const podsMiddleware = {
6 setBodyHostsPort,
7 setBodyHostPort
8}
9
10function setBodyHostsPort (req, res, next) {
11 if (!req.body.hosts) return next()
12
13 for (let i = 0; i < req.body.hosts.length; i++) {
14 const hostWithPort = getHostWithPort(req.body.hosts[i])
15
16 // Problem with the url parsing?
17 if (hostWithPort === null) {
18 return res.sendStatus(500)
19 }
20
21 req.body.hosts[i] = hostWithPort
22 }
23
24 return next()
25}
26
27function setBodyHostPort (req, res, next) {
28 if (!req.body.host) return next()
29
30 const hostWithPort = getHostWithPort(req.body.host)
31
32 // Problem with the url parsing?
33 if (hostWithPort === null) {
34 return res.sendStatus(500)
35 }
36
37 req.body.host = hostWithPort
38
39 return next()
40}
41
42// ---------------------------------------------------------------------------
43
44module.exports = podsMiddleware
45
46// ---------------------------------------------------------------------------
47
48function getHostWithPort (host) {
49 const splitted = host.split(':')
50
51 // The port was not specified
52 if (splitted.length === 1) {
53 if (constants.REMOTE_SCHEME.HTTP === 'https') return host + ':443'
54
55 return host + ':80'
56 }
57
58 return host
59}