linkifyjs icon indicating copy to clipboard operation
linkifyjs copied to clipboard

how do you enforce .find to require a protocol for strings that aren't emails?

Open fridaystreet opened this issue 1 year ago • 0 comments

I've just noticed in our editor that uses linkify to find links in typed or pasted text, that the library by default is returning that a string with a dot (and no protocol) in it is a valid url if the chars after the text are a valid tld.

Is there an option to disable this? I noticed in another library linkify-it, it has an option to disable fuzzyUrl matching which measn no protocol strings.

try the basic example below


const simpleStr = 'node.id'
const { find } = require('linkifyjs')
console.log(find(simpleStr))

\\returns
[
  {
    type: 'url',
    value: 'node.id',
    isLink: true,
    href: 'http://node.id',
    start: 0,
    end: 7
  }
]

Any assitance would be greatly appreciated. Thanks

fridaystreet avatar Oct 05 '24 11:10 fridaystreet