]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/helpers/custom-validators/webfinger.ts
Move models to typescript-sequelize
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
1 import { CONFIG } from '../../initializers'
2 import { exists } from './misc'
3
4 function isWebfingerResourceValid (value: string) {
5 if (!exists(value)) return false
6 if (value.startsWith('acct:') === false) return false
7
8 const accountWithHost = value.substr(5)
9 const accountParts = accountWithHost.split('@')
10 if (accountParts.length !== 2) return false
11
12 const host = accountParts[1]
13
14 return host === CONFIG.WEBSERVER.HOST
15 }
16
17 // ---------------------------------------------------------------------------
18
19 export {
20 isWebfingerResourceValid
21 }