Skip to content

Commit c3a9eb1

Browse files
authored
Merge pull request #11 from neilboyd/trailing-space
skip leading or trailing space
2 parents 6bee14d + 0d0f279 commit c3a9eb1

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

dest/simple-jekyll-search.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Simple-Jekyll-Search 1.13.1
2+
* Simple-Jekyll-Search 1.13.2
33
* Copyright 2015-2025, Christian Fei, Neil Boyd
44
* Licensed under the MIT License.
55
*/
@@ -323,6 +323,10 @@ function highlightMatchedText (value, query, snippetLength = 200) {
323323

324324
// highlight each match
325325
results.forEach((result) => {
326+
if (result.length === 0) {
327+
// first or last character is space
328+
return
329+
}
326330
let j = 0
327331
while (true) {
328332
j = value.toUpperCase().indexOf(result.toUpperCase(), j)

dest/simple-jekyll-search.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/js/simple-jekyll-search.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Simple-Jekyll-Search 1.13.1
2+
* Simple-Jekyll-Search 1.13.2
33
* Copyright 2015-2025, Christian Fei, Neil Boyd
44
* Licensed under the MIT License.
55
*/
@@ -323,6 +323,10 @@ function highlightMatchedText (value, query, snippetLength = 200) {
323323

324324
// highlight each match
325325
results.forEach((result) => {
326+
if (result.length === 0) {
327+
// first or last character is space
328+
return
329+
}
326330
let j = 0
327331
while (true) {
328332
j = value.toUpperCase().indexOf(result.toUpperCase(), j)

0 commit comments

Comments
 (0)