Socket
Socket
Sign inDemoInstall

fuzzysearch-highlight

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

LICENSE

2

index.js

@@ -8,3 +8,3 @@ module.exports = function highlight (query, text, opts) {

var offset = text.toLowerCase().indexOf(query[0])
var offset = text.toLowerCase().indexOf(query[0].toLowerCase())
if (offset === -1) return null

@@ -11,0 +11,0 @@

{
"name": "fuzzysearch-highlight",
"version": "1.0.1",
"version": "1.0.2",
"description": "Highlight fuzzy matched text",

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

# fuzzysearch-highlight
[![Build Status](https://travis-ci.org/uiureo/fuzzysearch-highlight.svg?branch=master)](https://travis-ci.org/uiureo/fuzzysearch-highlight)
Highlight fuzzy matched text with html.
This module is intended to be used with a module like [fuzzysearch](https://github.com/bevacqua/fuzzysearch).
```js

@@ -13,1 +17,4 @@ var highlight = require('fuzzysearch-highlight')

```
## License
ISC
var test = require('ava')
var highlight = require('./index.js')
test('match', function (t) {
test('match', (t) => {
t.is(

@@ -21,3 +21,12 @@ highlight('tqb', 'The quick brown fox'),

test('not match', function (t) {
test('query is uppercase', (t) => {
t.is(
highlight('TQB', 'The quick brown fox'),
'<strong>T</strong>he <strong>q</strong>uick <strong>b</strong>rown fox'
)
t.end()
})
test('not match', (t) => {
t.is(highlight('zzz', 'The quick brown fox'), null)

@@ -27,3 +36,3 @@ t.end()

test('specify tag', function (t) {
test('specify tag', (t) => {
t.is(

@@ -30,0 +39,0 @@ highlight('quick', 'The quick brown fox', { tag: 'em' }),

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