Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lunr

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunr - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

4

CHANGELOG.md
# Changelog
## 2.3.2
* Fix bug [#369](https://github.com/olivernn/lunr.js/issues/369) in parsing queries that include either a boost or edit distance modifier followed by a presence modifier on a subsequent term. Thanks [mtdjr](https://github.com/mtdjr) for reporting.
## 2.3.1

@@ -4,0 +8,0 @@

@@ -205,2 +205,5 @@ lunr.QueryParser = function (str, query) {

return lunr.QueryParser.parseBoost
case lunr.QueryLexer.PRESENCE:
parser.nextClause()
return lunr.QueryParser.parsePresence
default:

@@ -246,2 +249,5 @@ var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'"

return lunr.QueryParser.parseBoost
case lunr.QueryLexer.PRESENCE:
parser.nextClause()
return lunr.QueryParser.parsePresence
default:

@@ -248,0 +254,0 @@ var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'"

2

package.json
{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "2.3.1",
"version": "2.3.2",
"author": "Oliver Nightingale",

@@ -6,0 +6,0 @@ "keywords": ["search"],

@@ -186,2 +186,30 @@ suite('lunr.QueryLexer', function () {

suite('multiple terms with presence and fuzz', function () {
setup(function () {
this.lexer = lex('+foo~1 +bar')
})
test('produces n lexemes', function () {
assert.lengthOf(this.lexer.lexemes, 5)
})
suite('lexemes', function () {
setup(function () {
this.fooPresenceLexeme = this.lexer.lexemes[0]
this.fooTermLexeme = this.lexer.lexemes[1]
this.fooFuzzLexeme = this.lexer.lexemes[2]
this.barPresenceLexeme = this.lexer.lexemes[3]
this.barTermLexeme = this.lexer.lexemes[4]
})
test('#type', function () {
assert.equal(lunr.QueryLexer.PRESENCE, this.fooPresenceLexeme.type)
assert.equal(lunr.QueryLexer.TERM, this.fooTermLexeme.type)
assert.equal(lunr.QueryLexer.EDIT_DISTANCE, this.fooFuzzLexeme.type)
assert.equal(lunr.QueryLexer.PRESENCE, this.barPresenceLexeme.type)
assert.equal(lunr.QueryLexer.TERM, this.barTermLexeme.type)
})
})
})
suite('separator length > 1', function () {

@@ -188,0 +216,0 @@ setup(function () {

@@ -123,2 +123,68 @@ suite('lunr.QueryParser', function () {

suite('edit distance followed by presence', function () {
setup(function () {
this.clauses = parse('foo~10 +bar')
})
test('has 2 clause', function () {
assert.lengthOf(this.clauses, 2)
})
suite('clauses', function () {
setup(function () {
this.fooClause = this.clauses[0]
this.barClause = this.clauses[1]
})
test('#term', function () {
assert.equal('foo', this.fooClause.term)
assert.equal('bar', this.barClause.term)
})
test('#presence', function () {
assert.equal(lunr.Query.presence.OPTIONAL, this.fooClause.presence)
assert.equal(lunr.Query.presence.REQUIRED, this.barClause.presence)
})
test('#editDistance', function () {
assert.equal(10, this.fooClause.editDistance)
// It feels dirty asserting that something is undefined
// but there is no Optional so this is what we are reduced to
assert.isUndefined(this.barClause.editDistance)
})
})
})
suite('boost followed by presence', function () {
setup(function () {
this.clauses = parse('foo^10 +bar')
})
test('has 2 clause', function () {
assert.lengthOf(this.clauses, 2)
})
suite('clauses', function () {
setup(function () {
this.fooClause = this.clauses[0]
this.barClause = this.clauses[1]
})
test('#term', function () {
assert.equal('foo', this.fooClause.term)
assert.equal('bar', this.barClause.term)
})
test('#presence', function () {
assert.equal(lunr.Query.presence.OPTIONAL, this.fooClause.presence)
assert.equal(lunr.Query.presence.REQUIRED, this.barClause.presence)
})
test('#boost', function () {
assert.equal(10, this.fooClause.boost)
assert.equal(1, this.barClause.boost)
})
})
})
suite('field without a term', function () {

@@ -125,0 +191,0 @@ test('fails with lunr.QueryParseError', function () {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc