Encode TheBrain uuids to 22 characters slugs and decode slugs to uuids
This is useful to decode slugs from local thought url and create same url from BrainId and ThoughtId.
npm install thebrain-uuid-slug
const { uuidToSlug } = require('thebrain-uuid-slug')
const brainId = 'fd7bebf7-0ea0-40c9-b8c7-969e54c86136'
const thoughtId = 'd527957d-d57b-4af5-bb68-d527fd7d7b3b'
const localUrl = `brain://api.thebrain.com/${uuidToSlug(brainId)}/${uuidToSlug(thoughtId)}`
assert.equal(
localUrl,
'brain://api.thebrain.com/9-t7_aMOyUC4x5aeVMhhNg/fZUn1XvV9Uq3aNUn_X17Ow'
)
const { slugToUuid } = require('thebrain-uuid-slug')
const slug = '9-t7_aMOyUC4x5aeVMhhNg'
assert.equal(slugToUuid(slug), 'fd7bebf7-0ea3-40c9-b8c7-969e54c86136')