]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/helpers/custom-validators/webfinger.ts
Add subscriptions endpoints to REST API
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
1 import { CONFIG, REMOTE_SCHEME } from '../../initializers'
2 import { sanitizeHost } from '../core-utils'
3 import { exists } from './misc'
4
5 function isWebfingerLocalResourceValid (value: string) {
6 if (!exists(value)) return false
7 if (value.startsWith('acct:') === false) return false
8
9 const actorWithHost = value.substr(5)
10 const actorParts = actorWithHost.split('@')
11 if (actorParts.length !== 2) return false
12
13 const host = actorParts[1]
14 return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOST
15 }
16
17 // ---------------------------------------------------------------------------
18
19 export {
20 isWebfingerLocalResourceValid
21 }