Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion linkerd.io/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ window.addEventListener(
request.addEventListener("error", renderError, false);
request.send(null);
};
// Lunr's query parser treats characters like : + - * ~ ^ as query syntax,
// so remove them to keep user input literal and avoid throwing an error
// when a search term contains them.
// https://lunrjs.com/guides/searching.html#fields
const escapeLunrQuery = (text) => text.replace(/[:+\-*~^]/g, " ");
const renderSearchResults = () => {
const results = index.search(query);
let results;
try {
results = index.search(escapeLunrQuery(query));
} catch (e) {
renderError();
return;
}
// Remove loader
target.innerHTML = "";
// Render header
Expand Down
Loading