aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/servers.ts16
-rw-r--r--server/middlewares/validators/webfinger.ts4
2 files changed, 3 insertions, 17 deletions
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
index 488f9c368..87bbe9fd7 100644
--- a/server/middlewares/servers.ts
+++ b/server/middlewares/servers.ts
@@ -1,5 +1,6 @@
1import 'express-validator' 1import 'express-validator'
2import * as express from 'express' 2import * as express from 'express'
3import { getHostWithPort } from '../helpers'
3 4
4import { REMOTE_SCHEME } from '../initializers' 5import { REMOTE_SCHEME } from '../initializers'
5 6
@@ -25,18 +26,3 @@ function setBodyHostsPort (req: express.Request, res: express.Response, next: ex
25export { 26export {
26 setBodyHostsPort 27 setBodyHostsPort
27} 28}
28
29// ---------------------------------------------------------------------------
30
31function getHostWithPort (host: string) {
32 const splitted = host.split(':')
33
34 // The port was not specified
35 if (splitted.length === 1) {
36 if (REMOTE_SCHEME.HTTP === 'https') return host + ':443'
37
38 return host + ':80'
39 }
40
41 return host
42}
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 2c8351799..894c72498 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator/check' 2import { query } from 'express-validator/check'
3import { logger } from '../../helpers' 3import { getHostWithPort, logger } from '../../helpers'
4import { isWebfingerResourceValid } from '../../helpers/custom-validators/webfinger' 4import { isWebfingerResourceValid } from '../../helpers/custom-validators/webfinger'
5import { ActorModel } from '../../models/activitypub/actor' 5import { ActorModel } from '../../models/activitypub/actor'
6import { areValidationErrors } from './utils' 6import { areValidationErrors } from './utils'
@@ -14,7 +14,7 @@ const webfingerValidator = [
14 if (areValidationErrors(req, res)) return 14 if (areValidationErrors(req, res)) return
15 15
16 // Remove 'acct:' from the beginning of the string 16 // Remove 'acct:' from the beginning of the string
17 const nameWithHost = req.query.resource.substr(5) 17 const nameWithHost = getHostWithPort(req.query.resource.substr(5))
18 const [ name ] = nameWithHost.split('@') 18 const [ name ] = nameWithHost.split('@')
19 19
20 const actor = await ActorModel.loadLocalByName(name) 20 const actor = await ActorModel.loadLocalByName(name)