]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/webfinger.ts
Add hls support on server
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
CommitLineData
225a89c2
C
1import { CONFIG, REMOTE_SCHEME } from '../../initializers'
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]
604abfbe 14 return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOST
350e31d6
C
15}
16
17// ---------------------------------------------------------------------------
18
19export {
06a05d5f 20 isWebfingerLocalResourceValid
350e31d6 21}