Skip to content

Commit

Permalink
use webUri.origin and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgeoa committed May 22, 2024
1 parent 3f2eb27 commit 6a44656
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/models/account-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/account-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('AccountManager', () => {

const rootAcl = fs.readFileSync(path.join(accountDir, '.acl'), 'utf8')
expect(rootAcl).to.include('<mailto:alice@')
expect(rootAcl).to.include('<https://alice.example.com/profile/card#me>')
expect(rootAcl).to.include('</profile/card#me>')
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/integration/account-template-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/account-template-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('AccountTemplate', () => {
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount)
expect(substitutions.name).to.equal('Alice Q.')
expect(substitutions.email).to.equal('[email protected]')
expect(substitutions.webId).to.equal('https://alice.example.com/profile/card#me')
expect(substitutions.webId).to.equal('/profile/card#me')
})
})
})

0 comments on commit 6a44656

Please sign in to comment.