Skip to content

Commit 6e18d06

Browse files
authored
HTML search: Fix exact matching on titles with extra whitespace (#11770)
1 parent 2a589c0 commit 6e18d06

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)