Socket
Socket
Sign inDemoInstall

lunr

Package Overview
Dependencies
0
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.5 to 2.3.6

bower.json

4

CHANGELOG.md
# Changelog
## 2.3.6
* Fix bug [#390](https://github.com/olivernn/lunr.js/issues/390) with fuzzy matching that meant deletions at the end of a word would not match. Thanks [Luca Ongaro](https://github.com/lucaong) for reporting.
## 2.3.5

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

97

lib/token_set.js

@@ -129,25 +129,33 @@ /*!

if (frame.editsRemaining == 0) {
continue
}
// insertion
if ("*" in frame.node.edges) {
var insertionNode = frame.node.edges["*"]
} else {
var insertionNode = new lunr.TokenSet
frame.node.edges["*"] = insertionNode
}
if (frame.str.length == 0) {
insertionNode.final = true
}
stack.push({
node: insertionNode,
editsRemaining: frame.editsRemaining - 1,
str: frame.str
})
// deletion
// can only do a deletion if we have enough edits remaining
// and if there are characters left to delete in the string
if (frame.editsRemaining > 0 && frame.str.length > 1) {
var char = frame.str.charAt(1),
deletionNode
if (char in frame.node.edges) {
deletionNode = frame.node.edges[char]
} else {
deletionNode = new lunr.TokenSet
frame.node.edges[char] = deletionNode
}
if (frame.str.length <= 2) {
deletionNode.final = true
} else {
stack.push({
node: deletionNode,
editsRemaining: frame.editsRemaining - 1,
str: frame.str.slice(2)
})
}
if (frame.str.length > 1) {
stack.push({
node: frame.node,
editsRemaining: frame.editsRemaining - 1,
str: frame.str.slice(1)
})
}

@@ -157,3 +165,3 @@

// just removing the last character from the str
if (frame.editsRemaining > 0 && frame.str.length == 1) {
if (frame.str.length == 1) {
frame.node.final = true

@@ -165,3 +173,3 @@ }

// and if there are characters left to substitute
if (frame.editsRemaining > 0 && frame.str.length >= 1) {
if (frame.str.length >= 1) {
if ("*" in frame.node.edges) {

@@ -176,30 +184,9 @@ var substitutionNode = frame.node.edges["*"]

substitutionNode.final = true
} else {
stack.push({
node: substitutionNode,
editsRemaining: frame.editsRemaining - 1,
str: frame.str.slice(1)
})
}
}
// insertion
// can only do insertion if there are edits remaining
if (frame.editsRemaining > 0) {
if ("*" in frame.node.edges) {
var insertionNode = frame.node.edges["*"]
} else {
var insertionNode = new lunr.TokenSet
frame.node.edges["*"] = insertionNode
}
if (frame.str.length == 0) {
insertionNode.final = true
} else {
stack.push({
node: insertionNode,
editsRemaining: frame.editsRemaining - 1,
str: frame.str
})
}
stack.push({
node: substitutionNode,
editsRemaining: frame.editsRemaining - 1,
str: frame.str.slice(1)
})
}

@@ -210,3 +197,3 @@

// and there are enough characters to transpose
if (frame.editsRemaining > 0 && frame.str.length > 1) {
if (frame.str.length > 1) {
var charA = frame.str.charAt(0),

@@ -225,9 +212,9 @@ charB = frame.str.charAt(1),

transposeNode.final = true
} else {
stack.push({
node: transposeNode,
editsRemaining: frame.editsRemaining - 1,
str: charA + frame.str.slice(2)
})
}
stack.push({
node: transposeNode,
editsRemaining: frame.editsRemaining - 1,
str: charA + frame.str.slice(2)
})
}

@@ -234,0 +221,0 @@ }

{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "2.3.5",
"version": "2.3.6",
"author": "Oliver Nightingale",

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

@@ -297,3 +297,32 @@ suite('lunr.TokenSet', function () {

})
test('fuzzy string insertion', function () {
var x = lunr.TokenSet.fromString('abcxx'),
y = lunr.TokenSet.fromFuzzyString('abc', 2)
assert.sameMembers(x.intersect(y).toArray(), ['abcxx'])
})
test('fuzzy string substitution', function () {
var x = lunr.TokenSet.fromString('axx'),
y = lunr.TokenSet.fromFuzzyString('abc', 2)
assert.sameMembers(x.intersect(y).toArray(), ['axx'])
})
test('fuzzy string deletion', function () {
var x = lunr.TokenSet.fromString('a'),
y = lunr.TokenSet.fromFuzzyString('abc', 2)
assert.sameMembers(x.intersect(y).toArray(), ['a'])
})
test('fuzzy string transpose', function () {
var x = lunr.TokenSet.fromString('bca'),
y = lunr.TokenSet.fromFuzzyString('abc', 2)
assert.sameMembers(x.intersect(y).toArray(), ['bca'])
})
})
})

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc