iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 412 forks source link

Same route for multiple paths #727

Open dandv opened 10 years ago

dandv commented 10 years ago

Google autosuggests "iron router multiple" -> ""iron router multiple paths", but I haven't found documentation about this, or an SO question.

Something like this would be useful:

  this.route('foo', {
    path: ['/foo/:param1', '/bar/:param1'],
    ...
  }
cmather commented 10 years ago

What's the use case?

domarty commented 10 years ago

Off the top of my head: supporting legacy URLs.

grabbou commented 10 years ago

To support legacy URLs, we should rather create another option, called legacy that automatically redirects from every route specified there to path. The solution above will allow to enter that two URLs at the same time which is not definitely what we might expect.

trinisofttechnologies commented 8 years ago

+1

I have an app, which uses same thing for various route, just minor changes in the helpers

for example

  1. http://sharestuff.io/share/W8vJRKnz7naNTwJFb (this is a share link, view only mode)
  2. http://sharestuff.io/board/W8vJRKnz7naNTwJFb (If I am a user, I have access to read / write)
  3. http://sharestuff.io/embed/W8vJRKnz7naNTwJFb (I can use this link as iframe, and would not show, the menu bar)

So, for now, I have to write the same thing 3 times instead of once, and would reduce the code base.

Just a little hint. Thanks

LeNiglo commented 8 years ago

Hey !

Any updates on this one ?

A use case could simply be to make these routes the same :

You can do something like this to match the routes :

this.route('home', {
    path: /^(\/home|\/)$/
});

But the issue is that I'm not able to use :

<a href="{{ pathFor 'home' }}">Home</a>

As the path is a REGEX

This proposed path format (using arrays) would be a great help in my opinion. (and pathFor would take the first element in the array)