From 17fe2395bd70b2cc838bcf3f48f5c7a3c41edd87 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Thu, 16 May 2024 15:29:30 +0700 Subject: [PATCH] Fixed bug with converting URI to value Subdomains weren't working because of the missing trailing slash --- .../src/core/activitypub/actor.entity.test.ts | 15 +++++++++++++++ ghost/ghost/src/core/activitypub/uri.object.ts | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) 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); } }