millermedeiros / crossroads.js

JavaScript Routes
http://millermedeiros.github.com/crossroads.js/
1.44k stars 156 forks source link

Route rule that is an array seems to do a case sensitive match against route. #49

Closed ducka closed 12 years ago

ducka commented 12 years ago

I noticed if you define a rule that is an array of acceptable values on a route, the matching algorithim in crossroads does a case sensitive match against the the acceptable values. Is this the expected behavior? I would assume such a match would be case insensitive. It also doesn't mention anything about case sensitivity in your documentation.

var route = crossroads.addRoute("/{controller}/:action:", function(controller, action) {
    // do stuff...
});

router.rules = {
    controller: ["testcontroller"]
}

crossroads.parse("/TestController/action");

Thanks for writing this library. It's been a great help!

millermedeiros commented 12 years ago

uhm, good catch. When the rule is an Array it simply does an indexOf search. What do you feel would be the proper approach? Add a new setting to toggle behavior or make it case insensitive?

ducka commented 12 years ago

Ah I see. Well, I've only been using URL Routing libraries for a short while now, but I struggle to think of a situation where I would need case sensitivity in a URL. Perhaps making the match case insensitive without the behavior toggle would be appropriate? Can you think of a situation where you would need case sensitive matching?

millermedeiros commented 12 years ago

Yeah, it makes sense to always be case insensitive. Added it to the v0.9.0 bucket since I still didn't had time to release it (just missing the documentation). It's easy to implement and shouldn't affect legacy projects (since I also don't think case sensitivity matters in this case). Thanks for reporting it.

ducka commented 12 years ago

Awesome, thanks for that!

millermedeiros commented 12 years ago

@ducka I'm still unsure about this, specially since crossroads is case sensitive on the route matching, callbacks arguments and function validation rule. see #53 for more details.

ducka commented 12 years ago

Hmm, I've since come to realise this myself @millermedeiros... I'll comment on that other issue.