Skip to content

Commit a10889c

Browse files
authored
fix: encode ipns key correctly (#115)
Use `uint8ArrayToString` instead of calling `.toString()` on the Uint8Array instance directly.
1 parent 0a028be commit a10889c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ const extractPublicKey = (peerId, entry) => {
216216
*
217217
* @param {Uint8Array} key
218218
*/
219-
const rawStdEncoding = (key) => multibase.encode('base32', key).toString().slice(1).toUpperCase()
219+
const rawStdEncoding = (key) => uint8ArrayToString(multibase.encode('base32', key)).slice(1).toUpperCase()
220220

221221
/**
222222
* Get key for storing the record locally.

test/index.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ describe('ipns', function () {
130130
const datastoreKey = ipns.getLocalKey(fromB58String(ipfsId.id))
131131

132132
expect(datastoreKey).to.exist()
133+
expect(datastoreKey.toString()).to.startWith('/ipns/CIQ')
133134
})
134135

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

0 commit comments

Comments
 (0)