Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters can't have *s in them #1590

Open
edemaine opened this issue Aug 5, 2017 · 0 comments
Open

Parameters can't have *s in them #1590

edemaine opened this issue Aug 5, 2017 · 0 comments

Comments

@edemaine
Copy link

edemaine commented Aug 5, 2017

I have a regular route (no wildcards), and a form submission that triggers a Router.go, like so:

Router.route '/:group/search/:search',
  name: 'search'
  subscriptions: -> [
    Subscribe.subscribe 'messages.search', @params.group, @params.search
    Subscribe.subscribe 'groups.members', @params.group
    Subscribe.subscribe 'files', @params.group
  ]
  data: ->
    group: @params.group
    search: @params.search

Template.layout.events
  'submit .searchForm': (e, t) ->
    e.preventDefault()
    e.stopPropagation()
    Router.go 'search',
      group: routeGroup()
      search: t.find('.searchText').value

However, if the user enters text with one or more asterisks (*), this throws an error You are trying to access a wild card parameter at index 0 but the value of params at that index is undefined. The same happens with pathFor and urlFor, as reported in #708. The workaround I've found is the following:

    Router.go 'search',
      group: routeGroup()
      search: t.find('.searchText').value
      0: '*'
      1: '*'
      2: '*'
      3: '*'
      4: '*'
      5: '*'
      6: '*'
      7: '*'
      8: '*'
      9: '*'

But this still limits the number of asterisks the user can enter to 10. Fine for now, but feels like a bug (and it's been annoying to work around it every time I use pathFor and urlFor). It seems that *s should only be interpreted in the route specification, not in the arguments... or maybe I don't understand what wildcards are for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant