X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Factivitypub.ts;h=4bf6e387dde27c8b93bc76c1eec48877175ff68f;hb=ae28cdf327d782e629379eee1999096ca2a5d74b;hp=b0bcfe8242b48e9cfd29cb8641e846c02b042183;hpb=1cf8aca11dcfec76e72cdb0edfb49bfc2bf4fdd8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index b0bcfe824..4bf6e387d 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -6,6 +6,7 @@ import { ACTIVITY_PUB } from '../initializers' import { ActorModel } from '../models/activitypub/actor' import { signJsonLDObject } from './peertube-crypto' import { pageToStartAndCount } from './core-utils' +import { parse } from 'url' function activityPubContextify (data: T) { return Object.assign(data, { @@ -111,9 +112,17 @@ function getActorUrl (activityActor: string | ActivityPubActor) { return activityActor.id } +function checkUrlsSameHost (url1: string, url2: string) { + const idHost = parse(url1).host + const actorHost = parse(url2).host + + return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase() +} + // --------------------------------------------------------------------------- export { + checkUrlsSameHost, getActorUrl, activityPubContextify, activityPubCollectionPagination,