rails/rails — Issue #5114: Tilde character breaks scoped routes (worked in 3.1)
Author: tomlanning
Created: 2012-02-21 14:43:16+00:00
State: open

Routing does not function properly in 3.2.1(Ruby 1.8.7) when scope contains a tilde (~) character. This worked properly in 3.1.

Reproduce the problem by creating a new project.

```sh
$ rails new generic
$ cd generic
$ rails generate controller home index
$ rm public/index.html
```
Edit routes.rb to be,

```ruby
Generic::Application.routes.draw do
scope '/~user' do
root :to => "home#index"
end
end
```

Start the console,

```sh
$ bundle exec rails console
1.8.7-p352 :001 > app.root_url
=> "http://www.example.com/~user"
1.8.7-p352 :002 > app.get(app.root_url)
=> 404
```

Notice the return of (404) instead of the expected (200). If you remove the tilde (~) character from the scope in routes.rb

```ruby
Generic::Application.routes.draw do
scope '/user' do
root :to => "home#index"
end
end
```

the results in the console are as expected, i.e. (200).

```sh
bundle exec rails console
Loading development environment (Rails 3.2.1)
1.8.7-p352 :001 > app.root_url
=> "http://www.example.com/user"
1.8.7-p352 :002 > app.get(app.root_url)
=> 200
```

Again, this worked fine in the previous versions of 3.1. This regression prevents me from publishing applications on shared service ISPs that restrict sites to include (.../~user) as the application root. Any fix or work-arounds would be appreciated.