rails/rails — Issue #4400: exclamation point in routes
Author: sethvargo
Created: 2012-01-10 16:28:11+00:00
State: open

In my application, I would like to create static pages namespaced under the '!' (exclamation point). For example:

/!/about
/!/faq

Currently, I have it functional using the prefix "pages" in my `routes.rb` file:

```ruby
# config/routes.rb
get 'pages(/:action)' => 'pages', :as => :page
```

This works great, and generates the correct URLs, etc. However, if I replace pages with !, the routes fail:

```ruby
# config/routes.rb
get '!(/:action)'...
```

Here's the output of rake routes:

```
...
pages GET /!(.:format) {:controller=>"pages", :action=>"index"}
page GET /!/:action(.:format) {:controller=>"pages"}
```
As you can see, Rails is generating the routes. However, when I try to use any of those named routes in my views, I get a routing error:

`No route matches {:controller => "pages", :action => "about"}`

Ironically, If I use any other symbol (like `@` or even `#`) the routes work as expected. Why can't I use an `!` exclamation point in my routes?

## Additional Information
It also fails if I specify the route manually `{:controller => :pages, :action => :about}` with the same error.

The routes actually work if visited directly (`/!/about`) renders the correct page. The URL helpers just won't let it actually create the link.

I'm aware that, according to [RFC3986 Uniform Resource Identifier: Generic Syntax](http://labs.apache.org/webarch/uri/rfc/rfc3986.html#reserved_), `!` is a reserved character in a URL. However, Rails let's me use other special characters also reserved, without hassle.

I speculate it has something to do with the way the routes are processed. Is it interpreting `!` as negation instead of the literal character? I've tried escaping it, but without success.