]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/webfinger.ts
Add subscriptions endpoints to REST API
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / webfinger.ts
index 1b9aad444f0ac835d91e0d3b3d2a37816ff59b00..80a7e4a9d9c46d28baa0aecd9e1434ee751e746d 100644 (file)
@@ -1,7 +1,8 @@
-import { CONFIG } from '../../initializers'
+import { CONFIG, REMOTE_SCHEME } from '../../initializers'
+import { sanitizeHost } from '../core-utils'
 import { exists } from './misc'
 
-function isWebfingerResourceValid (value: string) {
+function isWebfingerLocalResourceValid (value: string) {
   if (!exists(value)) return false
   if (value.startsWith('acct:') === false) return false
 
@@ -10,12 +11,11 @@ function isWebfingerResourceValid (value: string) {
   if (actorParts.length !== 2) return false
 
   const host = actorParts[1]
-
-  return host === CONFIG.WEBSERVER.HOSTNAME || host === CONFIG.WEBSERVER.HOST
+  return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOST
 }
 
 // ---------------------------------------------------------------------------
 
 export {
-  isWebfingerResourceValid
+  isWebfingerLocalResourceValid
 }