const isValidMultihash = function (hash) { try { return typeof multihashes.validate(multihashes.fromB58String(hash)) === 'undefined' } catch (e) { return false } }
onKeyupAddressBar(e) { if (e.which === 13) { let text = this.$addressBar.val(); let isGuid = true; if (text.startsWith('ob://')) text = text.slice(5); const firstTerm = text.split(' ')[0]; try { multihashes.validate(multihashes.fromB58String(firstTerm)); } catch (exc) { isGuid = false; } // temporary way to check for GUIDs, since our dummy guids from // start.js aren't valid v2 guids, but are registered with the // one-name api. if (firstTerm.startsWith('Qm')) isGuid = true; // end - temporary guid check if (isGuid) { app.router.navigate(firstTerm, { trigger: true }); } else if (firstTerm.charAt(0) === '@' && firstTerm.length > 1) { // a handle app.router.navigate(firstTerm, { trigger: true }); } else { // tag(s) const tags = text.trim() .replace(',', ' ') .replace(/\s+/g, ' ') // collapse multiple spaces into single spaces .split(' ') .map((frag) => (frag.charAt(0) === '#' ? frag.slice(1) : frag)); alert(`boom - Searching for tags: ${tags.join(', ')}`); } } }