Comparing version 2.3.7 to 2.3.8
# Changelog | ||
## 2.3.8 | ||
* Fix bug [#422](https://github.com/olivernn/lunr.js/issues/422) where a pipline function that returned null was not skipping the token as described in the documentation. Thanks [Stephen Cleary](https://github.com/StephenCleary) and [Rob Hoelz](https://github.com/hoelzro) for reporting and investigating. | ||
## 2.3.7 | ||
@@ -4,0 +8,0 @@ |
@@ -47,4 +47,4 @@ /*! | ||
* 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. | ||
* null, undefined or an empty string. This token will not be passed to any downstream pipeline | ||
* functions and will not be added to the index. | ||
* | ||
@@ -212,3 +212,3 @@ * Multiple tokens can be returned by returning an array of tokens. Each token will be passed | ||
if (result === void 0 || result === '') continue | ||
if (result === null || result === void 0 || result === '') continue | ||
@@ -215,0 +215,0 @@ if (Array.isArray(result)) { |
{ | ||
"name": "lunr", | ||
"description": "Simple full-text search in your browser.", | ||
"version": "2.3.7", | ||
"version": "2.3.8", | ||
"author": "Oliver Nightingale", | ||
@@ -6,0 +6,0 @@ "keywords": ["search"], |
@@ -145,3 +145,3 @@ suite('lunr.Pipeline', function () { | ||
test('filters out undefined values', function () { | ||
test('filters out null, undefined and empty string values', function () { | ||
var tokens = [], | ||
@@ -151,5 +151,14 @@ output | ||
// only pass on tokens for even token indexes | ||
// return null for 'foo' | ||
// return undefined for 'bar' | ||
// return '' for 'baz' | ||
this.pipeline.add(function (t, i) { | ||
if (i % 2) { | ||
if (i == 4) { | ||
return null | ||
} else if (i == 5) { | ||
return '' | ||
} if (i % 2) { | ||
return t | ||
} else { | ||
return undefined | ||
} | ||
@@ -163,3 +172,3 @@ }) | ||
output = this.pipeline.run(['a', 'b', 'c', 'd']) | ||
output = this.pipeline.run(['a', 'b', 'c', 'd', 'foo', 'bar', 'baz']) | ||
@@ -166,0 +175,0 @@ assert.sameMembers(['b', 'd'], tokens) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
975822
80
28762