Skip to content

Commit

Permalink
fix: encode ipns key correctly (#115)
Browse files Browse the repository at this point in the history
Use `uint8ArrayToString` instead of calling `.toString()` on the
Uint8Array instance directly.
  • Loading branch information
achingbrain authored Apr 13, 2021
1 parent 0a028be commit a10889c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const extractPublicKey = (peerId, entry) => {
*
* @param {Uint8Array} key
*/
const rawStdEncoding = (key) => multibase.encode('base32', key).toString().slice(1).toUpperCase()
const rawStdEncoding = (key) => uint8ArrayToString(multibase.encode('base32', key)).slice(1).toUpperCase()

/**
* Get key for storing the record locally.
Expand Down
1 change: 1 addition & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('ipns', function () {
const datastoreKey = ipns.getLocalKey(fromB58String(ipfsId.id))

expect(datastoreKey).to.exist()
expect(datastoreKey.toString()).to.startWith('/ipns/CIQ')
})

it('should get id keys correctly', () => {
Expand Down

0 comments on commit a10889c

Please sign in to comment.