Skip to content

Commit

Permalink
added function to also strip port, updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zg009 committed May 21, 2024
1 parent a5ab656 commit 3f2eb27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/models/account-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions test/integration/account-template-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3f2eb27

Please sign in to comment.