]>
Commit | Line | Data |
---|---|---|
74dc3bca | 1 | import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants' |
225a89c2 | 2 | import { sanitizeHost } from '../core-utils' |
350e31d6 C |
3 | import { exists } from './misc' |
4 | ||
06a05d5f | 5 | function 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 | ||
19 | export { | |
06a05d5f | 20 | isWebfingerLocalResourceValid |
350e31d6 | 21 | } |