From 6a44656881061f0fb72cfe3d5a393ee4a3f7d5a0 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Wed, 22 May 2024 17:49:11 +0200 Subject: [PATCH] use webUri.origin and update tests --- lib/models/account-template.js | 3 +-- test/integration/account-manager-test.js | 2 +- test/integration/account-template-test.js | 4 ++-- test/unit/account-template-test.js | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/models/account-template.js b/lib/models/account-template.js index 7cc9c85ef..ddb65c7f6 100644 --- a/lib/models/account-template.js +++ b/lib/models/account-template.js @@ -74,8 +74,7 @@ class AccountTemplate { */ static templateSubstitutionsFor (userAccount) { const webUri = new URL(userAccount.webId) - const webIdOrigin = webUri.protocol + '//' + webUri.hostname + ':' + webUri.port - const podRelWebId = userAccount.webId.replace(webIdOrigin, '') + const podRelWebId = userAccount.webId.replace(webUri.origin, '') const substitutions = { name: userAccount.displayName, webId: userAccount.externalWebId ? userAccount.webId : podRelWebId, diff --git a/test/integration/account-manager-test.js b/test/integration/account-manager-test.js index 6eaaa3b30..a939dfce3 100644 --- a/test/integration/account-manager-test.js +++ b/test/integration/account-manager-test.js @@ -139,7 +139,7 @@ describe('AccountManager', () => { const rootAcl = fs.readFileSync(path.join(accountDir, '.acl'), 'utf8') expect(rootAcl).to.include('') + expect(rootAcl).to.include('') }) }) }) diff --git a/test/integration/account-template-test.js b/test/integration/account-template-test.js index c6803b4db..02d195a57 100644 --- a/test/integration/account-template-test.js +++ b/test/integration/account-template-test.js @@ -73,7 +73,7 @@ describe('AccountTemplate', () => { const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) - expect(substitutions.webId).to.equal('https://alice.example.com/#me') + expect(substitutions.webId).to.equal('/#me') }) it('should not update the nested webid', () => { @@ -85,7 +85,7 @@ describe('AccountTemplate', () => { const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) - expect(substitutions.webId).to.equal('https://alice.example.com/alice/#me') + expect(substitutions.webId).to.equal('/alice/#me') }) it('should update the webid', () => { diff --git a/test/unit/account-template-test.js b/test/unit/account-template-test.js index 67bdf18e7..3a2bd43be 100644 --- a/test/unit/account-template-test.js +++ b/test/unit/account-template-test.js @@ -54,7 +54,7 @@ describe('AccountTemplate', () => { const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) expect(substitutions.name).to.equal('Alice Q.') expect(substitutions.email).to.equal('alice@example.com') - expect(substitutions.webId).to.equal('https://alice.example.com/profile/card#me') + expect(substitutions.webId).to.equal('/profile/card#me') }) }) })