Skip to content

Commit

Permalink
fix: did:peer:2 abbreviations not working quite right
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm committed Nov 7, 2023
1 parent 3d21f4b commit 1d9ba83
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/lib/peer2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,14 @@ export default class DIDPeer {
const expanded = Object.fromEntries(
Object.entries(input).map(([key, value]) => {
const expandedKey = reverseCommonStringAbbreviations[key] || key
const expandedValue =
typeof value === "string"
? reverseCommonStringAbbreviations[value] || value
: value
let expandedValue = value;
if (typeof value == "string") {
expandedValue = reverseCommonStringAbbreviations[value] || value
} else if (Array.isArray(value)) {
expandedValue = value.map((item: any) => reverseCommonStringAbbreviations[item] || item)
} else if (typeof value == "object") {
expandedValue = DIDPeer.expandCommonStringAbbreviations(expandedValue)
}
return [expandedKey, expandedValue]
})
)
Expand All @@ -128,10 +132,14 @@ export default class DIDPeer {
const abbreviated = Object.fromEntries(
Object.entries(input).map(([key, value]) => {
const abbreviatedKey = commonStringAbbreviations[key] || key
const abbreviatedValue =
typeof value === "string"
? commonStringAbbreviations[value] || value
: value
let abbreviatedValue = value
if (typeof value == "string") {
abbreviatedValue = commonStringAbbreviations[value] || value
} else if (Array.isArray(value)) {
abbreviatedValue = value.map((item: any) => commonStringAbbreviations[item] || item)
} else if (typeof value == "object") {
abbreviatedValue = DIDPeer.abbreviateCommonStrings(abbreviatedValue)
}
return [abbreviatedKey, abbreviatedValue]
})
)
Expand Down

0 comments on commit 1d9ba83

Please sign in to comment.