Skip to content

Commit 3f2eb27

Browse files
committed
added function to also strip port, updated test cases
1 parent a5ab656 commit 3f2eb27

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/models/account-template.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class AccountTemplate {
7474
*/
7575
static templateSubstitutionsFor (userAccount) {
7676
const webUri = new URL(userAccount.webId)
77-
const webIdOrigin = webUri.protocol + '//' + webUri.hostname
77+
const webIdOrigin = webUri.protocol + '//' + webUri.hostname + ':' + webUri.port
7878
const podRelWebId = userAccount.webId.replace(webIdOrigin, '')
7979
const substitutions = {
8080
name: userAccount.displayName,

test/integration/account-template-test.js

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ describe('AccountTemplate', () => {
7676
expect(substitutions.webId).to.equal('https://alice.example.com/#me')
7777
})
7878

79+
it('should not update the nested webid', () => {
80+
const userAccount = new UserAccount({
81+
webId: 'https://alice.example.com/alice/#me',
82+
83+
name: 'Alice Q.'
84+
})
85+
86+
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount)
87+
88+
expect(substitutions.webId).to.equal('https://alice.example.com/alice/#me')
89+
})
90+
7991
it('should update the webid', () => {
8092
const userAccount = new UserAccount({
8193
webId: 'http://localhost:8443/alice/#me',

0 commit comments

Comments
 (0)