Fixed bug with converting URI to value

Subdomains weren't working because of the missing trailing slash
This commit is contained in:
Fabien O'Carroll 2024-05-16 15:29:30 +07:00 committed by Fabien 'egg' O'Carroll
parent 5e0f1a1732
commit 17fe2395bd
2 changed files with 17 additions and 1 deletions

View File

@ -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 () {

View File

@ -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);
}
}