olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.94k stars 548 forks source link

Pipeline functions returning null does not discard token #422

Closed StephenCleary closed 4 years ago

StephenCleary commented 4 years ago

The documentation states "A pipeline function can indicate that the passed token should be discarded by returning null. This token will not be passed to any downstream pipeline functions and will not be added to the index."

However, the code checks for undefined or empty string, and will pass null tokens through to the next pipeline function.

hoelzro commented 4 years ago

Can confirm via fiddle

The documentation for the module itself implies that undefined is indeed the right value to return, and there's a test that backs this up

hoelzro commented 4 years ago

I've submitted a PR to address this: #423

olivernn commented 4 years ago

I think the right fix here is to treat a null in the same way the code currently treats undefined and ""

@hoelzro thanks for the pull request, but I think we can take this opportunity to make the code match the documentation! I'll put together a change with a fix just now.

olivernn commented 4 years ago

I've just pushed 2.3.8 which includes a fix for this issue, thanks for taking the time to report and to @hoelzro for investigating.