Suport new base36 format, Improve unwieldy logic

This commit is contained in:
phillmac 2020-06-24 18:24:42 +10:00
parent 56b5583d16
commit 6b7af61b10

View File

@ -26,8 +26,18 @@ class OrbitDBAddress {
let accessControllerHash
const validateHash = (hash) => {
const prefixes = ['zd', 'Qm', 'ba', 'k5']
for (const p of prefixes) {
if (hash.indexOf(p) > -1) {
return true
}
}
return false
}
try {
accessControllerHash = (parts[0].indexOf('zd') > -1 || parts[0].indexOf('Qm') > -1 || parts[0].indexOf('ba') > -1)
accessControllerHash = validateHash(parts[0])
? new CID(parts[0]).toBaseEncodedString()
: null
} catch (e) {