Skip to content

Add clean_query() to Lookup - #15

Merged
bpepple merged 1 commit into
mainfrom
clean-query
Nov 3, 2026
Merged

bpepple merged 1 commit into
mainfrom
clean-query

Conversation

@bpepple

@bpepple bpepple commented Nov 3, 2026

Copy link
Copy Markdown
Member

The search view always stripped surrounding whitespace from q, so a lookup couldn't use whitespace in its search. For example, a leading space can't mean "match a later word".

Lookup.clean_query(query) now turns the raw search text into the text passed to search. By default it strips surrounding whitespace, so existing lookups behave the same.

  • min_length and max_query_length apply to the cleaned text.
  • A query that is only whitespace is never searched, even if clean_query keeps it.
  • NUL characters are still removed before clean_query runs.

The README's lookup options table and the CHANGELOG are updated.

Tests cover the default stripping, a lookup that keeps a leading space (LaterWordLookup), queries that are only whitespace, and min_length counting the cleaned text.

The search view always stripped surrounding whitespace from the query, so a lookup couldn't treat whitespace as meaningful, for example a leading space meaning "match a later word".

Lookup.clean_query() now turns the raw q parameter into the text passed to search. By default it strips surrounding whitespace, as before. min_length and max_query_length apply to the cleaned text, and a query that is only whitespace is still never searched, whatever clean_query keeps.
@bpepple bpepple self-assigned this Nov 3, 2026
@bpepple bpepple added enhancement New feature or request minor labels Nov 3, 2026
@bpepple
bpepple merged commit 53b32ff into main Nov 3, 2026
6 checks passed
@bpepple
bpepple deleted the clean-query branch November 3, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant