I would like to have an option for bangs to trim whitespace from custom bang queries.
I wish it were the default, but since it isn't now doing that would probably break the workflows of some people if they happen to be doing things where leading/trailing whitespace matters. It seems like a rare use case, but not impossible. So it would probably be better to make it an option when creating/editing a bang. Maybe it could be the default for newly created ones though, if you decide that makes sense.
I have a few bangs that I regularly use with search terms that I'm copying and pasting from HTML tables, and so my terms often accidentally wind up with leading and/or trailing whitespace, and in some circumstances the endpoint won't trim it either and it breaks my results.
I think it's intuitive to trim whitespace, because that is the behavior of a lot of online forms. It's also easy to miss leading/trailing whitespace visually, so it can make a search that looks like it should work not work in a way that might be confusing for people.
EDIT for a specific example: the one it's the biggest headache for is a bang I have set up as:
Bang !ip with the URL template https://ipinfo.io/%s
Then if I'm copying/pasting an IP into that bang from a table of log data somewhere, it might wind up with whitespace before it, and will resolve to a broken URL like https://ipinfo.io/%20%0943.163.109.15