Skip to content

Commit 2085cc5

Browse files
authored
Merge pull request #12 from neilboyd/b
fix infinite loop when search for b
2 parents 9f1ae3c + 3874275 commit 2085cc5

File tree

8 files changed

+23
-29
lines changed

8 files changed

+23
-29
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on: [push]
33
jobs:
44
build_deploy:
55
runs-on: ubuntu-22.04
6+
timeout-minutes: 5
67
steps:
78
- name: Checkout
89
uses: actions/checkout@v4

dest/simple-jekyll-search.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Simple-Jekyll-Search 1.13.2
2+
* Simple-Jekyll-Search 1.13.3
33
* Copyright 2015-2025, Christian Fei, Neil Boyd
44
* Licensed under the MIT License.
55
*/
@@ -334,13 +334,9 @@ function highlightMatchedText (value, query, snippetLength = 200) {
334334
break
335335
}
336336
const k = j + result.length
337-
value =
338-
value.substring(0, j) +
339-
'<b>' +
340-
value.substring(j, k) +
341-
'</b>' +
342-
value.substring(k)
343-
j += 4 // move past the previous match
337+
const highlighted = '<b>' + value.substring(j, k) + '</b>'
338+
value = value.substring(0, j) + highlighted + value.substring(k)
339+
j += highlighted.length // move past the previous match
344340
}
345341
})
346342

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: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Simple-Jekyll-Search 1.13.2
2+
* Simple-Jekyll-Search 1.13.3
33
* Copyright 2015-2025, Christian Fei, Neil Boyd
44
* Licensed under the MIT License.
55
*/
@@ -334,13 +334,9 @@ function highlightMatchedText (value, query, snippetLength = 200) {
334334
break
335335
}
336336
const k = j + result.length
337-
value =
338-
value.substring(0, j) +
339-
'<b>' +
340-
value.substring(j, k) +
341-
'</b>' +
342-
value.substring(k)
343-
j += 4 // move past the previous match
337+
const highlighted = '<b>' + value.substring(j, k) + '</b>'
338+
value = value.substring(0, j) + highlighted + value.substring(k)
339+
j += highlighted.length // move past the previous match
344340
}
345341
})
346342

0 commit comments

Comments
 (0)