Closed ExigoOffice closed 10 years ago
MVC has the action first since the controller is optional. If you don't specify the controller name, it will use the current controller. In RouteJs the controller is always required, so I decided to put it first so that the arguments follow a logical order. Looking back, I'm not sure whether that was a good decision or not. Maybe it's worth accepting them in either order (take first param as controller and second param as action, but fall back to using first param as action and second param as controller if no matching route is found)?
One more loop through wouldn't be too much of a performance hit for most sites What I'd be scared about is the possibility of someone's project having a controller-action name pairing that might actually exist when reversed.
I tend to follow convention myself, but your decision logic makes sense. Quirky, but easily forgivable in my book.
BTW, your project here is great - simple and effective! It's inspired me to do the same thing for my culture code provider (makes all C#-string formatting available in JS based on the .NET CultureCode).
Yeah I was worried about the same thing. Could add it as a config option but that'd make the code a bit more complex. I like that it's reasonably simple at the moment.
I was curious why the decision was made to define the controller as the first argument as opposed to the action, which is the pattern MVC implements.