Repository navigation
Add clean_query() to Lookup - #15
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The search view always stripped surrounding whitespace from
q, so a lookup couldn't use whitespace in itssearch. 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 tosearch. By default it strips surrounding whitespace, so existing lookups behave the same.min_lengthandmax_query_lengthapply to the cleaned text.clean_querykeeps it.clean_queryruns.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, andmin_lengthcounting the cleaned text.