How to use the twitter-text.autoLinkEntities function in twitter-text

To help you get started, we’ve selected a few twitter-text 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 tec27 / seatcamp / lib / chat-sockets.js View on Github external
function transformText(text) {
  const sanitized = text.slice(0, 250).replace(/[\r\n\t]/, '')
  const entities = twitterText.extractEntitiesWithIndices(sanitized, {
    extractUrlsWithoutProtocol: true,
  })
  const linkified = twitterText.autoLinkEntities(sanitized, entities, {
    htmlEscapeNonEntities: true,
    targetBlank: true,
    usernameIncludeSymbol: true,
  })

  return linkified
}