From 3f2eb2706541f715e83f0543310a0d3cbe679ab4 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 21 May 2024 18:15:14 -0500 Subject: [PATCH] added function to also strip port, updated test cases --- lib/models/account-template.js | 2 +- test/integration/account-template-test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/models/account-template.js b/lib/models/account-template.js index d7a300cc..7cc9c85e 100644 --- a/lib/models/account-template.js +++ b/lib/models/account-template.js @@ -74,7 +74,7 @@ class AccountTemplate { */ static templateSubstitutionsFor (userAccount) { const webUri = new URL(userAccount.webId) - const webIdOrigin = webUri.protocol + '//' + webUri.hostname + const webIdOrigin = webUri.protocol + '//' + webUri.hostname + ':' + webUri.port const podRelWebId = userAccount.webId.replace(webIdOrigin, '') const substitutions = { name: userAccount.displayName, diff --git a/test/integration/account-template-test.js b/test/integration/account-template-test.js index 44632f95..c6803b4d 100644 --- a/test/integration/account-template-test.js +++ b/test/integration/account-template-test.js @@ -76,6 +76,18 @@ describe('AccountTemplate', () => { expect(substitutions.webId).to.equal('https://alice.example.com/#me') }) + it('should not update the nested webid', () => { + const userAccount = new UserAccount({ + webId: 'https://alice.example.com/alice/#me', + email: 'alice@example.com', + name: 'Alice Q.' + }) + + const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) + + expect(substitutions.webId).to.equal('https://alice.example.com/alice/#me') + }) + it('should update the webid', () => { const userAccount = new UserAccount({ webId: 'http://localhost:8443/alice/#me',