]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/activitypub/misc.ts
Make the client compile too
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / activitypub / misc.ts
CommitLineData
e4f97bab
C
1import { exists } from '../misc'
2
3function isActivityPubUrlValid (url: string) {
4 const isURLOptions = {
5 require_host: true,
6 require_tld: true,
7 require_protocol: true,
8 require_valid_protocol: true,
9 protocols: [ 'http', 'https' ]
10 }
11
12 return exists(url) && validator.isURL(url, isURLOptions)
13}
14
0d0e8dd0
C
15function isBaseActivityValid (activity: any, type: string) {
16 return Array.isArray(activity['@context']) &&
17 activity.type === type &&
18 validator.isURL(activity.id) &&
19 validator.isURL(activity.actor) &&
20 Array.isArray(activity.to) &&
21 activity.to.every(t => validator.isURL(t))
22}
23
e4f97bab 24export {
0d0e8dd0
C
25 isActivityPubUrlValid,
26 isBaseActivityValid
e4f97bab 27}