Trailing spaces in search query cause route to be fired twice #1793
Description
Using Backbone.history with pushState disabled, navigating to a search route with one or more trailing spaces, the route is incorrectly triggered twice.
For example:
Backbone.history.navigate('search/space ', {trigger: true});
Looking into it further, when the fragment is added to window.location, the trailing spaces are trimmed and thus when Backbone.history.checkUrl() is called, it detects that the hash fragment has changed and triggers the route again.
To illustrate the problem, I added a gist showing two tests: https://gist.github.com/3998698
The first test uses the 'mock' Backbone.history.location from the test setup which passes. When Backbone.history.location is replaced with window.location (as it would be in actual use), the same test fails because the route is triggered twice.
I'll submit a Pull Request in a moment with a potential fix for the issue (along with the above tests).