diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-14 17:31:26 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad (patch) | |
tree | f4191f3c04a5230fcf8ca3d6ca3248643fc4151d /server/helpers/custom-validators/webfinger.ts | |
parent | e34c85e527100c0b5c44567bd951e95be41b8d7e (diff) | |
download | PeerTube-350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad.tar.gz PeerTube-350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad.tar.zst PeerTube-350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad.zip |
Follow works
Diffstat (limited to 'server/helpers/custom-validators/webfinger.ts')
-rw-r--r-- | server/helpers/custom-validators/webfinger.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/webfinger.ts b/server/helpers/custom-validators/webfinger.ts new file mode 100644 index 000000000..e93115d81 --- /dev/null +++ b/server/helpers/custom-validators/webfinger.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import 'express-validator' | ||
2 | import 'multer' | ||
3 | import { CONFIG } from '../../initializers/constants' | ||
4 | import { exists } from './misc' | ||
5 | |||
6 | function isWebfingerResourceValid (value: string) { | ||
7 | if (!exists(value)) return false | ||
8 | if (value.startsWith('acct:') === false) return false | ||
9 | |||
10 | const accountWithHost = value.substr(5) | ||
11 | const accountParts = accountWithHost.split('@') | ||
12 | if (accountParts.length !== 2) return false | ||
13 | |||
14 | const host = accountParts[1] | ||
15 | |||
16 | if (host !== CONFIG.WEBSERVER.HOST) return false | ||
17 | |||
18 | return true | ||
19 | } | ||
20 | |||
21 | // --------------------------------------------------------------------------- | ||
22 | |||
23 | export { | ||
24 | isWebfingerResourceValid | ||
25 | } | ||