Skip to content

Commit

Permalink
Clone options for multiple string terms in Query#term
Browse files Browse the repository at this point in the history
  • Loading branch information
mike1808 authored and olivernn committed Jun 18, 2018
1 parent 70e9f8c commit bb4578c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ lunr.Query.prototype.isNegated = function () {
*/
lunr.Query.prototype.term = function (term, options) {
if (Array.isArray(term)) {
term.forEach(function (t) { this.term(t, options) }, this)
term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)
return this
}

Expand Down
11 changes: 11 additions & 0 deletions test/query_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ suite('lunr.Query', function () {
})
})

suite('multiple string terms with options', function () {
setup(function () {
this.query.term(['foo', 'bar'], { usePipeline: false })
})

test('clause has the correct term', function () {
var terms = this.query.clauses.map(function (c) { return c.term })
assert.sameMembers(terms, ['foo', 'bar'])
})
})

suite('multiple token terms', function () {
setup(function () {
this.query.term(lunr.tokenizer('foo bar'))
Expand Down

0 comments on commit bb4578c

Please sign in to comment.