diff options
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index ef6a878cf..769aa83c6 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -2,13 +2,26 @@ import * as express from 'express' | |||
2 | import { Model } from 'sequelize-typescript' | 2 | import { Model } from 'sequelize-typescript' |
3 | import { ResultList } from '../../shared' | 3 | import { ResultList } from '../../shared' |
4 | import { VideoResolution } from '../../shared/models/videos' | 4 | import { VideoResolution } from '../../shared/models/videos' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG, REMOTE_SCHEME } from '../initializers' |
6 | import { UserModel } from '../models/account/user' | 6 | import { UserModel } from '../models/account/user' |
7 | import { ActorModel } from '../models/activitypub/actor' | 7 | import { ActorModel } from '../models/activitypub/actor' |
8 | import { ApplicationModel } from '../models/application/application' | 8 | import { ApplicationModel } from '../models/application/application' |
9 | import { pseudoRandomBytesPromise } from './core-utils' | 9 | import { pseudoRandomBytesPromise } from './core-utils' |
10 | import { logger } from './logger' | 10 | import { logger } from './logger' |
11 | 11 | ||
12 | function getHostWithPort (host: string) { | ||
13 | const splitted = host.split(':') | ||
14 | |||
15 | // The port was not specified | ||
16 | if (splitted.length === 1) { | ||
17 | if (REMOTE_SCHEME.HTTP === 'https') return host + ':443' | ||
18 | |||
19 | return host + ':80' | ||
20 | } | ||
21 | |||
22 | return host | ||
23 | } | ||
24 | |||
12 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { | 25 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { |
13 | return res.type('json').status(400).end() | 26 | return res.type('json').status(400).end() |
14 | } | 27 | } |
@@ -108,5 +121,6 @@ export { | |||
108 | computeResolutionsToTranscode, | 121 | computeResolutionsToTranscode, |
109 | resetSequelizeInstance, | 122 | resetSequelizeInstance, |
110 | getServerActor, | 123 | getServerActor, |
111 | SortType | 124 | SortType, |
125 | getHostWithPort | ||
112 | } | 126 | } |