diff --git a/ghost/ghost/src/core/activitypub/actor.entity.test.ts b/ghost/ghost/src/core/activitypub/actor.entity.test.ts index d4c6650ddf..b4887f4920 100644 --- a/ghost/ghost/src/core/activitypub/actor.entity.test.ts +++ b/ghost/ghost/src/core/activitypub/actor.entity.test.ts @@ -25,6 +25,21 @@ describe('Actor', function () { assert.equal(doesnaeHaveDisplayName.displayName, 'username'); }); }); + + describe('actorId', function () { + it('Correctly returns the actor url', function () { + const actor = Actor.create({username: 'testing'}); + const idString = actor.id.toHexString(); + const actorId = actor.actorId; + + const baseUrl = new URL('https://domain.tld/base'); + + assert.equal( + actorId.getValue(baseUrl), + `https://domain.tld/base/actor/${idString}` + ); + }); + }); }); describe('#createArticle', function () { diff --git a/ghost/ghost/src/core/activitypub/uri.object.ts b/ghost/ghost/src/core/activitypub/uri.object.ts index 440af95c89..a25316e505 100644 --- a/ghost/ghost/src/core/activitypub/uri.object.ts +++ b/ghost/ghost/src/core/activitypub/uri.object.ts @@ -6,6 +6,7 @@ export class URI extends URL { } getValue(url: URL) { - return this.href.replace(URI.BASE_URL.href, url.href); + const replaceValue = url.href.endsWith('/') ? url.href : url.href + '/'; + return this.href.replace(URI.BASE_URL.href, replaceValue); } }