Skip to content

Commit 451de8e

Browse files
committed
Fix exact matching on title when there are leading/trailing spaces
When there is a search term with whitespace (e.g. ` Superman`), the override to boost entries that match on the title (e.g. `Superman`) didn't work.
1 parent 3596590 commit 451de8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sphinx/themes/basic/static/searchtools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ const Search = {
288288
let results = [];
289289
_removeChildren(document.getElementById("search-progress"));
290290

291-
const queryLower = query.toLowerCase();
291+
const queryLower = query.toLowerCase().trim();
292292
for (const [title, foundTitles] of Object.entries(allTitles)) {
293-
if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) {
293+
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
294294
for (const [file, id] of foundTitles) {
295295
let score = Math.round(100 * queryLower.length / title.length)
296296
results.push([

0 commit comments

Comments
 (0)