]>
Commit | Line | Data |
---|---|---|
69818c93 C |
1 | import 'express-validator' |
2 | import * as express from 'express' | |
0405ab52 | 3 | import { getHostWithPort } from '../helpers' |
69818c93 | 4 | |
e02643f3 | 5 | import { REMOTE_SCHEME } from '../initializers' |
1ab844d8 | 6 | |
69818c93 | 7 | function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) { |
b09ce645 C |
8 | if (!req.body.hosts) return next() |
9 | ||
49abbbbe C |
10 | for (let i = 0; i < req.body.hosts.length; i++) { |
11 | const hostWithPort = getHostWithPort(req.body.hosts[i]) | |
1ab844d8 C |
12 | |
13 | // Problem with the url parsing? | |
49abbbbe | 14 | if (hostWithPort === null) { |
1ab844d8 C |
15 | return res.sendStatus(500) |
16 | } | |
17 | ||
49abbbbe | 18 | req.body.hosts[i] = hostWithPort |
1ab844d8 C |
19 | } |
20 | ||
21 | return next() | |
22 | } | |
23 | ||
1ab844d8 C |
24 | // --------------------------------------------------------------------------- |
25 | ||
65fcc311 | 26 | export { |
d4f1e94c | 27 | setBodyHostsPort |
65fcc311 | 28 | } |