Creating case-inensitive route components?


#1

Hi,

On my new Rails based site I’d like to allow parts of the
URLs accepted to be case-insensitive. That is, these should
all be accepted:

  http://example.org/foo/action
  http://example.org/Foo/action
  http://example.org/FOO/action

  etc.

I’ve setup a route like this in routes.rb:

ActionController::Routing::Routes.draw do |map|
map.connect ‘:foo/something’,
:foo => /foo/i,
:controller => ‘foo’,
:action => ‘something’

 ...

But that doesn’t seem to work for :foo components in anything
but lower case.

If I use this route:

ActionController::Routing::Routes.draw do |map|
map.connect ‘:foo/something’,
:foo => /[fF][oO][oO]/,
:controller => ‘foo’,
:action => ‘something’

 ...

That does work. Can someone explain what’s happening here?

Stu