]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/webfinger.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
CommitLineData
74dc3bca 1import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants'
225a89c2 2import { sanitizeHost } from '../core-utils'
350e31d6
C
3import { exists } from './misc'
4
06a05d5f 5function isWebfingerLocalResourceValid (value: string) {
350e31d6
C
6 if (!exists(value)) return false
7 if (value.startsWith('acct:') === false) return false
8
50d6de9c
C
9 const actorWithHost = value.substr(5)
10 const actorParts = actorWithHost.split('@')
11 if (actorParts.length !== 2) return false
350e31d6 12
50d6de9c 13 const host = actorParts[1]
6dd9de95 14 return sanitizeHost(host, REMOTE_SCHEME.HTTP) === WEBSERVER.HOST
350e31d6
C
15}
16
17// ---------------------------------------------------------------------------
18
19export {
06a05d5f 20 isWebfingerLocalResourceValid
350e31d6 21}