Skip to content

Commit 6a44656

Browse files
committed
use webUri.origin and update tests
1 parent 3f2eb27 commit 6a44656

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

lib/models/account-template.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class AccountTemplate {
7474
*/
7575
static templateSubstitutionsFor (userAccount) {
7676
const webUri = new URL(userAccount.webId)
77-
const webIdOrigin = webUri.protocol + '//' + webUri.hostname + ':' + webUri.port
78-
const podRelWebId = userAccount.webId.replace(webIdOrigin, '')
77+
const podRelWebId = userAccount.webId.replace(webUri.origin, '')
7978
const substitutions = {
8079
name: userAccount.displayName,
8180
webId: userAccount.externalWebId ? userAccount.webId : podRelWebId,

test/integration/account-manager-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('AccountManager', () => {
139139

140140
const rootAcl = fs.readFileSync(path.join(accountDir, '.acl'), 'utf8')
141141
expect(rootAcl).to.include('<mailto:alice@')
142-
expect(rootAcl).to.include('<https://alice.example.com/profile/card#me>')
142+
expect(rootAcl).to.include('</profile/card#me>')
143143
})
144144
})
145145
})

test/integration/account-template-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('AccountTemplate', () => {
7373

7474
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount)
7575

76-
expect(substitutions.webId).to.equal('https://alice.example.com/#me')
76+
expect(substitutions.webId).to.equal('/#me')
7777
})
7878

7979
it('should not update the nested webid', () => {
@@ -85,7 +85,7 @@ describe('AccountTemplate', () => {
8585

8686
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount)
8787

88-
expect(substitutions.webId).to.equal('https://alice.example.com/alice/#me')
88+
expect(substitutions.webId).to.equal('/alice/#me')
8989
})
9090

9191
it('should update the webid', () => {

test/unit/account-template-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('AccountTemplate', () => {
5454
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount)
5555
expect(substitutions.name).to.equal('Alice Q.')
5656
expect(substitutions.email).to.equal('[email protected]')
57-
expect(substitutions.webId).to.equal('https://alice.example.com/profile/card#me')
57+
expect(substitutions.webId).to.equal('/profile/card#me')
5858
})
5959
})
6060
})

0 commit comments

Comments
 (0)