Skip to content

Commit

Permalink
fix: correctly parse multiple service blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Colton Wolkins (Laptop) <[email protected]>
  • Loading branch information
TheTechmage committed Dec 1, 2023
1 parent 7381290 commit 2ccc9de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/peer2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ export default class DIDPeer {
const doc: any = {
"@context": "https://www.w3.org/ns/did/v1",
id: did,
service: [],
}
let serviceIndex = 0;

elements.forEach(element => {
const purposeCode = element.charAt(0)
Expand Down Expand Up @@ -229,13 +231,14 @@ export default class DIDPeer {
.map((service: any) => {
// TODO This is a bandaid! Mediator should include id in services.
if (!("id" in service)) {
service.id = "#service"
let suffix = serviceIndex++ > 0 ? "" : `-${serviceIndex}`
service.id = `#service${suffix}`
}
return service
})
.map(DIDPeer.transformOldServiceStyleToNew)

doc.service = services
doc.service.push(...services)
break
}

Expand Down

0 comments on commit 2ccc9de

Please sign in to comment.