Commit f360b75824e9bd1e15f8928424e85e42326fda49
fix link encoding
wanderer committed on 3/22/2018, 7:16:17 PMParent: e61d25798db079eb20435ebc17b0e9f1f2da20fa
Files changed
datastore.js | changed |
datastore.js | ||
---|---|---|
@@ -5,8 +5,15 @@ | ||
5 | 5 | const cbor = require('borc') |
6 | 6 | |
7 | 7 | module.exports = class TreeDAG extends DAG { |
8 | 8 | async put (val) { |
9 | + if (val[1]) { | |
10 | + val[1] = new cbor.Tagged(42, val[1]['/']) | |
11 | + } | |
12 | + | |
13 | + if (val[2]) { | |
14 | + val[2] = new cbor.Tagged(42, val[2]['/']) | |
15 | + } | |
9 | 16 | const encoded = cbor.encode(val) |
10 | 17 | const key = await TreeDAG.getMerkleLink(encoded) |
11 | 18 | |
12 | 19 | return new Promise((resolve, reject) => { |
@@ -23,8 +30,15 @@ | ||
23 | 30 | reject(err) |
24 | 31 | } else { |
25 | 32 | val = Buffer.from(val, 'hex') |
26 | 33 | const decoded = cbor.decode(val) |
34 | + if (decoded[1]) { | |
35 | + decoded[1]['/'] = decoded[1].value | |
36 | + } | |
37 | + | |
38 | + if (decoded[2]) { | |
39 | + decoded[2]['/'] = decoded[2].value | |
40 | + } | |
27 | 41 | resolve(decoded) |
28 | 42 | } |
29 | 43 | }) |
30 | 44 | }) |
Built with git-ssb-web