Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Make search queries optional in Backbone router
Browse files Browse the repository at this point in the history
Before this change: logged in users going to `/public/search` get redirected to `/help`. Now: it correctly redirects to `/search/`.

Using the trailing slash, with or without a query, *did* work, so this just fixes a weird edge case.
  • Loading branch information
reefdog committed Sep 23, 2016
1 parent f415bac commit be8d48d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions public/javascripts/app/searcher.js
Expand Up @@ -25,10 +25,10 @@ dc.controllers.Searcher = Backbone.Router.extend({
flags : {},

routes : {
'search/*query/p:page': 'searchByHash',
'search/*query': 'searchByHash',
'public/search/*query/p:page': 'dummyPublicSearch',
'public/search/*query': 'dummyPublicSearch'
'search(/*query/p:page)': 'searchByHash',
'search(/*query)': 'searchByHash',
'public/search(/*query/p:page)': 'dummyPublicSearch',
'public/search(/*query)': 'dummyPublicSearch'
},

// Creating a new SearchBox registers #search page fragments.
Expand Down

1 comment on commit be8d48d

@reefdog
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This title is actually a little wrong; queries were always optional, we're just explicitly wrapping the trailing slash and the query in parens to indicate the whole thing is optional.

Please sign in to comment.