fuzzysearch-highlight
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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 |
15
test.js
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' }), |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
4030
7
52
20
1