Skip to content

Commit

Permalink
Trim search query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Nov 23, 2024
1 parent 92136a0 commit 18e8bc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ext/js/display/query-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,14 @@ export class QueryParser extends EventDispatcher {
termNode.className = 'query-parser-term';
termNode.dataset.offset = `${offset}`;
for (const {text, reading} of term) {
const trimmedText = text.trim();
if (reading.length === 0) {
termNode.appendChild(document.createTextNode(text));
termNode.appendChild(document.createTextNode(trimmedText));
} else {
const reading2 = this._convertReading(text, reading);
termNode.appendChild(this._createSegment(text, reading2, offset));
const reading2 = this._convertReading(trimmedText, reading);
termNode.appendChild(this._createSegment(trimmedText, reading2, offset));
}
offset += text.length;
offset += trimmedText.length;
}
fragment.appendChild(termNode);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/js/display/search-display-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class SearchDisplayController {
this._searchBackButton.hidden = !showBackButton;

if (this._queryInput.value !== query) {
this._queryInput.value = query;
this._queryInput.value = query.trim();
this._updateSearchHeight(true);
}
this._setIntroVisible(!valid, animate);
Expand Down

0 comments on commit 18e8bc6

Please sign in to comment.