webfinger.ts 652 B

123456789101112131415161718192021
  1. import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants'
  2. import { sanitizeHost } from '../core-utils'
  3. import { exists } from './misc'
  4. function isWebfingerLocalResourceValid (value: string) {
  5. if (!exists(value)) return false
  6. if (value.startsWith('acct:') === false) return false
  7. const actorWithHost = value.substr(5)
  8. const actorParts = actorWithHost.split('@')
  9. if (actorParts.length !== 2) return false
  10. const host = actorParts[1]
  11. return sanitizeHost(host, REMOTE_SCHEME.HTTP) === WEBSERVER.HOST
  12. }
  13. // ---------------------------------------------------------------------------
  14. export {
  15. isWebfingerLocalResourceValid
  16. }