]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/webfinger.ts
Redirect to uuid video route after upload
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
CommitLineData
3fd3ab2d 1import { CONFIG } from '../../initializers'
350e31d6
C
2import { exists } from './misc'
3
4function isWebfingerResourceValid (value: string) {
5 if (!exists(value)) return false
6 if (value.startsWith('acct:') === false) return false
7
50d6de9c
C
8 const actorWithHost = value.substr(5)
9 const actorParts = actorWithHost.split('@')
10 if (actorParts.length !== 2) return false
350e31d6 11
50d6de9c 12 const host = actorParts[1]
350e31d6 13
232f04c8 14 return host === CONFIG.WEBSERVER.HOSTNAME || host === CONFIG.WEBSERVER.HOST
350e31d6
C
15}
16
17// ---------------------------------------------------------------------------
18
19export {
20 isWebfingerResourceValid
21}