How to use the ssb-ref.feedIdRegex function in ssb-ref

To help you get started, we’ve selected a few ssb-ref examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-server / plugins / gossip.js View on Github external
}

function isObject (o) {
  return o && typeof o === 'object'
}

function toBase64 (s) {
  if (isString(s)) return s
  else s.toString('base64') // assume a buffer
}

function isString (s) {
  return typeof s === 'string'
}

var feedIdRegex = new RegExp(ref.feedIdRegex)

function toMultiserverAddress (address) {
  if (isObject(address)) {
    if (ref.isFeed(address.key)) {
      address.key = address.key.match(feedIdRegex)[1]
    }
    var protocol = 'net'
    if (address.host.endsWith('.onion')) { protocol = 'onion' }
    return [protocol, address.host, address.port].join(':') + '~' + ['shs', toBase64(address.key)].join(':')
  }
  return address
}
github staltz / manyverse / src / frontend / components / Markdown.ts View on Github external
function Markdown(markdownText: string) {
  const linkifySsbFeeds = linkifyRegex(Ref.feedIdRegex);
  const linkifySsbMsgs = linkifyRegex(Ref.msgIdRegex);

  return $(ReactMarkdown, {
    source: remark()
      .use(gemojiToEmoji)
      .use(linkifySsbFeeds)
      .use(linkifySsbMsgs)
      .use(imagesToSsbServeBlobs)
      .processSync(markdownText).contents,
    astPlugins: [normalizeForReactNative()],
    allowedTypes: Object.keys(renderers),
    renderers,
  });
}