How to use the `validate` function with `find`? Doesn't seem to be working!
rfgamaral opened this issue · 5 comments
Hi there,
I'm trying to use the validate
function with find
, but it doesn't seem to be working:
import { find } from 'linkifyjs'
const content = `[GitHub](https://github.com)
[Linkify](https://linkify.js.org "Linkify: a JS plugin by Hypercontext")`
const testA1 = find(content, {
validate: false
})
const testA2 = find(content, {
validate: () => false
})
const testA3 = find(content, {
validate: {
url: () => false
}
})
const testB1 = find(content, 'url', {
validate: false
})
const testB2 = find(content, 'url', {
validate: () => false
})
const testB3 = find(content, 'url', {
validate: {
url: () => false
}
})
console.log(testA1, testA2, testA3)
console.log(testB1, testB2, testB3)
Output:
CodeSandbox:
Am I using it wrong, or is there an issue somewhere?
@rfgamaral thanks for reporting, this is a bug in the find
function. Will fix this to the next release. In the mean time, you can try .filter()
or something similar on the result of .find()
to further filter out matches
@nfrasser I don't think that will work for what I'm trying to achieve, which is to prevent linkify from capturing links enclosed in Markdown syntax. But if you have any workaround suggestions, please, do let me know.
For the record, I want to apply this filtering here, most likely based on a boolean option so that it's user configurable.
@rfgamaral apologies for the delay, this is now working with the latest Linkify v4.1.2