]>
Commit | Line | Data |
---|---|---|
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 | } |