Add `?trim:bool` param to `Dream.query`?
yawaramin opened this issue · 6 comments
Or perhaps even just trim the values automatically?
E.g. some clients might send queries like ?q=
(with no value) or ?q=
(single space character as the value).
In these cases perhaps we should evaluate to None
for Dream.query ~trim:true req "q"
?
Would you be willing to make a PR for this, calling the option ?filter_empty
?
@yawaramin did you start working on that one? I haven't checked the code yet but that looks like something that shouldn't be too difficult to implement so I would be happy to try :)
@yawaramin what was the original context for this? What client was sending ?q=
or ?q=
, and in what circumstance? Is there some kind of inconsistency between clients in this behavior?
@aantron so I'm using the htmx library and implementing the Active Search pattern with it, by default it makes the query request even if the input field value is empty:
<input hx-trigger="keyup changed delay:500ms"...
Since then I made it slightly more sophisticated to not send the query if the input is empty:
<input hx-trigger="keyup[target.value.trim() != ''] changed delay:400ms"...
But I admit the original use case for me is not relevant any more. You would be justified to close the issue.
I'm going to close this as something very specific to a certain use case (which may not exist) and easily implementable by Dream's users when needed.