Skip to content

Commit ea0aa4d

Browse files
taylorarndtCopilot
andcommitted
Fix search results not appearing (broken regex in template literal)
The highlight regex used \] and \/ inside a template literal which dropped the backslashes in output, causing a JS SyntaxError that silently killed the entire search script. Replaced with a simple alphanumeric strip which avoids the escaping issue entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 91ac06e commit ea0aa4d

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

html/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ <h1>Search</h1>
140140
// Highlight matching words in snippet
141141
words.forEach(function (w) {
142142
if (!w) return;
143-
var escaped = w.replace(/[-[]/{}()*+?.\^$|]/g, '');
143+
var escaped = w.replace(/[^a-zA-Z0-9]/g, '');
144144
if (!escaped) return;
145145
var re = new RegExp('(' + escaped + ')', 'gi');
146146
snippet = snippet.replace(re, '<mark>$1</mark>');

scripts/build-html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ function buildSearchPage(outputDir) {
802802
// Highlight matching words in snippet
803803
words.forEach(function (w) {
804804
if (!w) return;
805-
var escaped = w.replace(/[-[\]/{}()*+?.\\^$|]/g, '');
805+
var escaped = w.replace(/[^a-zA-Z0-9]/g, '');
806806
if (!escaped) return;
807807
var re = new RegExp('(' + escaped + ')', 'gi');
808808
snippet = snippet.replace(re, '<mark>$1</mark>');

0 commit comments

Comments
 (0)