]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/webfinger.ts
Federate video views
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
CommitLineData
350e31d6
C
1import 'express-validator'
2import 'multer'
3import { CONFIG } from '../../initializers/constants'
4import { exists } from './misc'
5
6function isWebfingerResourceValid (value: string) {
7 if (!exists(value)) return false
8 if (value.startsWith('acct:') === false) return false
9
10 const accountWithHost = value.substr(5)
11 const accountParts = accountWithHost.split('@')
12 if (accountParts.length !== 2) return false
13
14 const host = accountParts[1]
15
16 if (host !== CONFIG.WEBSERVER.HOST) return false
17
18 return true
19}
20
21// ---------------------------------------------------------------------------
22
23export {
24 isWebfingerResourceValid
25}