diff --git a/src/address.js b/src/address.js index 2c98762..f942c1d 100644 --- a/src/address.js +++ b/src/address.js @@ -58,21 +58,21 @@ const parseAddress = (address) => { } const OrbitDBAddress = (address) => { - if (address && address.protocol === 'orbitdb' && address.path) { + if (address && address.protocol === 'orbitdb' && address.hash) { return address } const protocol = 'orbitdb' - const path = address.replace('/orbitdb/', '').replace('\\orbitdb\\', '') + const hash = address.replace('/orbitdb/', '').replace('\\orbitdb\\', '') const toString = () => { - return posixJoin('/', protocol, path) + return posixJoin('/', protocol, hash) } return { protocol, - path, + hash, address, toString } diff --git a/src/orbitdb.js b/src/orbitdb.js index d34f2d8..2e0a5c3 100644 --- a/src/orbitdb.js +++ b/src/orbitdb.js @@ -115,7 +115,7 @@ const OrbitDB = async ({ ipfs, id, identities, directory } = {}) => { if (isValidAddress(address)) { // If the address given was a valid OrbitDB address, eg. '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13' const addr = OrbitDBAddress(address) - manifest = await manifestStore.get(addr.path) + manifest = await manifestStore.get(addr.hash) const acType = manifest.accessController.split('/', 2).pop() const acAddress = manifest.accessController.replaceAll(`/${acType}/`, '') AccessController = getAccessController(acType)() diff --git a/test/orbit-db-address.test.js b/test/orbit-db-address.test.js index e72bbd5..9bcad41 100644 --- a/test/orbit-db-address.test.js +++ b/test/orbit-db-address.test.js @@ -18,7 +18,7 @@ describe('Address', function () { it('has a path', () => { const address = '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13' const addr = OrbitDBAddress(address) - strictEqual(addr.path, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') + strictEqual(addr.hash, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') }) }) @@ -38,7 +38,7 @@ describe('Address', function () { it('has a path', () => { const address = 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13' const addr = OrbitDBAddress(address) - strictEqual(addr.path, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') + strictEqual(addr.hash, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') }) }) @@ -61,7 +61,7 @@ describe('Address', function () { }) it('has a path', () => { - strictEqual(addr2.path, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') + strictEqual(addr2.hash, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') }) }) @@ -128,7 +128,7 @@ describe('Address', function () { const result = parseAddress(address) strictEqual(result.protocol, 'orbitdb') - strictEqual(result.path, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') + strictEqual(result.hash, 'zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13') strictEqual(result.toString().indexOf('/orbitdb'), 0) strictEqual(result.toString().indexOf('zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13'), 9) @@ -139,7 +139,7 @@ describe('Address', function () { const result = parseAddress(address) strictEqual(result.protocol, 'orbitdb') - strictEqual(result.path, 'Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzcJC') + strictEqual(result.hash, 'Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzcJC') strictEqual(result.toString().indexOf('/orbitdb'), 0) strictEqual(result.toString().indexOf('Qmdgwt7w4uBsw8LXduzCd18zfGXeTmBsiR8edQ1hSfzcJC'), 9)