HTML search: Fix exact matching on titles with extra whitespace (#11770)

This commit is contained in:
Will Lachance 2023-12-26 02:21:18 -05:00 committed by GitHub
parent 2a589c09b2
commit 6e18d06d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -288,9 +288,9 @@ const Search = {
let results = [];
_removeChildren(document.getElementById("search-progress"));
const queryLower = query.toLowerCase();
const queryLower = query.toLowerCase().trim();
for (const [title, foundTitles] of Object.entries(allTitles)) {
if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) {
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
for (const [file, id] of foundTitles) {
let score = Math.round(100 * queryLower.length / title.length)
results.push([