]>
Commit | Line | Data |
---|---|---|
225a89c2 C |
1 | import { CONFIG, REMOTE_SCHEME } from '../../initializers' |
2 | import { sanitizeHost } from '../core-utils' | |
350e31d6 C |
3 | import { exists } from './misc' |
4 | ||
5 | function isWebfingerResourceValid (value: string) { | |
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] |
350e31d6 | 14 | |
225a89c2 | 15 | return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOSTNAME |
350e31d6 C |
16 | } |
17 | ||
18 | // --------------------------------------------------------------------------- | |
19 | ||
20 | export { | |
21 | isWebfingerResourceValid | |
22 | } |