Skip to content

Commit 439fcc0

Browse files
authored
fix: local key for datastore
1 parent d7c90ef commit 439fcc0

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"base32-encode": "^1.1.0",
3737
"big.js": "^5.1.2",
3838
"debug": "^3.1.0",
39+
"interface-datastore": "^0.4.2",
3940
"left-pad": "^1.3.0",
4041
"nano-date": "^2.1.0",
4142
"protons": "^1.0.1"

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const base32Encode = require('base32-encode')
44
const Big = require('big.js')
55
const NanoDate = require('nano-date').default
6+
const { Key } = require('interface-datastore')
67

78
const debug = require('debug')
89
const log = debug('jsipns')
@@ -132,7 +133,7 @@ const rawStdEncoding = (key) => base32Encode(key, 'RFC4648', { padding: false })
132133
* @param {Buffer} key peer identifier object.
133134
* @returns {string}
134135
*/
135-
const getLocalKey = (key) => `/ipns/${rawStdEncoding(key)}`
136+
const getLocalKey = (key) => new Key(`/ipns/${rawStdEncoding(key)}`)
136137

137138
/**
138139
* Get key for sharing the record in the routing mechanism.

test/index.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ describe('ipns', function () {
140140
const datastoreKey = ipns.getLocalKey(fromB58String(ipfsId.id))
141141

142142
expect(datastoreKey).to.exist()
143-
expect(datastoreKey).to.startsWith('/ipns/')
144143
})
145144

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

0 commit comments

Comments
 (0)