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

js-solr-highlighter

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-solr-highlighter - npm Package Compare versions

Comparing version 0.8.7 to 0.8.8

14

build/index.js

@@ -100,3 +100,3 @@ "use strict";

// remove any char that is neither letter nor number at the start and end of each term
const terms = term.split(/\s/).map(t => t.replace(/^[^a-zA-Z0-9]+/, '').replace(/[^a-zA-Z0-9]+$/, ''));
const terms = term.split(/\s/).map(t => t.replace(/^[^a-zA-Z0-9]+/, '').replace(/[^a-zA-Z0-9\*]+$/, ''));
return words.concat(terms);

@@ -142,5 +142,15 @@ }

}
// highlight one word by another
// some filters may be moved up***
words = words.filter(word => word.length && !isStopWord(word) && !['AND', 'OR', 'NOT'].includes(word));
for (let i = 0; i < words.length; i++) {
if (words[i].endsWith('*')) {
words[i] = words[i].slice(0, words[i].length - 1);
let index = content.indexOf(words[i]) + words[i].length;
while (content[index] !== ' ' && index !== content.length - 1) {
words[i] += content[index];
index++;
}
}
}
// highlight one word by another
let newContent = content;

@@ -147,0 +157,0 @@ if (words.length) {

@@ -126,3 +126,3 @@ "use strict";

.split(/\s/)
.map((t) => t.replace(/^[^a-zA-Z0-9]+/, '').replace(/[^a-zA-Z0-9]+$/, ''));
.map((t) => t.replace(/^[^a-zA-Z0-9]+/, '').replace(/[^a-zA-Z0-9\*]+$/, ''));
return words.concat(terms);

@@ -187,5 +187,15 @@ }

}
// highlight one word by another
// some filters may be moved up***
words = words.filter((word) => word.length && !isStopWord(word) && !['AND', 'OR', 'NOT'].includes(word));
for (let i = 0; i < words.length; i++) {
if (words[i].endsWith('*')) {
words[i] = words[i].slice(0, words[i].length - 1);
let index = content.indexOf(words[i]) + words[i].length;
while (content[index] !== ' ' && index !== content.length - 1) {
words[i] += content[index];
index++;
}
}
}
// highlight one word by another
let newContent = content;

@@ -192,0 +202,0 @@ if (words.length) {

@@ -579,2 +579,12 @@ import { isStopWord, highlightByQuery } from './dist/index.js'

})
test('fuzzy query *', () => {
const query = 'Bre*'
const content =
'Editorial: The Role of Breast Cancer Stem Cells in Clinical Outcomes.'
const received = highlightByQuery(query, content)
const expected =
'Editorial: The Role of <span id="highlight-0" class="highlight">Breast</span> Cancer Stem Cells in Clinical Outcomes.'
expect(received).toBe(expected)
})
})

@@ -581,0 +591,0 @@

@@ -147,3 +147,3 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment

.map((t) =>
t.replace(/^[^a-zA-Z0-9]+/, '').replace(/[^a-zA-Z0-9]+$/, '')
t.replace(/^[^a-zA-Z0-9]+/, '').replace(/[^a-zA-Z0-9\*]+$/, '')
)

@@ -218,3 +218,2 @@ return words.concat(terms)

// highlight one word by another
// some filters may be moved up***

@@ -225,2 +224,14 @@ words = words.filter(

)
for (let i = 0; i < words.length; i++) {
if (words[i].endsWith('*')) {
words[i] = words[i].slice(0, words[i].length - 1)
let index = content.indexOf(words[i]) + words[i].length;
while(content[index] !== ' ' && index !== content.length - 1) {
words[i] += content[index]
index++
}
}
}
// highlight one word by another
let newContent = content

@@ -227,0 +238,0 @@ if (words.length) {

2

package.json
{
"name": "js-solr-highlighter",
"version": "0.8.7",
"version": "0.8.8",
"description": "A JavaScript library for highlighting HTML text based on the query in the lucene/solr query syntax",

@@ -5,0 +5,0 @@ "main": "build/index.js",

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