Closed Ranhiru closed 1 year ago
Hello!
I am attempting to match some particular words and trying to linkify them.
See example below.
linkify.add('nda agreement', { validate: function (text, pos, self) { return 1; }, normalize: function (match) { match.url = 'https://www.my-website.com/real-nda-agreement-link'; } }); linkify.add('other agreement', { validate: function (text, pos, self) { return 1; }, normalize: function (match) { match.url = 'https://www.my-website.com/real-other-agreement-link'; } }); const text = `I, [name of user], agree to the NDA agreement & other agreement.` console.log(linkify.match(text));
this returns
[ Match { schema: 'nda agreement', index: 32, lastIndex: 46, raw: 'NDA agreement ', text: 'NDA agreement ', url: 'https://www.my-website.com/real-nda-agreement-link' }, Match { schema: 'other agreement', index: 48, lastIndex: 64, raw: 'other agreement.', text: 'other agreement.', url: 'https://www.my-website.com/real-other-agreement-link' } ]
the issue I'm trying to fix is that if that if I return 0 from the validate function, the match is not included in the list of matchers.
validate
How do I tell the validate function to stop checking tail after link prefix ?
This package is not suitable for any text pattern matching. It's intended to match URL-s, those MUST start with protocol.
protocol
Hello!
I am attempting to match some particular words and trying to linkify them.
See example below.
this returns
the issue I'm trying to fix is that if that if I return 0 from the
validate
function, the match is not included in the list of matchers.How do I tell the validate function to stop checking tail after link prefix ?