Tilde character breaks scoped routes (worked in 3.1) #5114

Closed
tomlanning opened this Issue Feb 21, 2012 · 6 comments

Projects

None yet

3 participants

@tomlanning

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.

$ rails new generic
$ cd generic
$ rails generate controller home index
$ rm public/index.html

Edit routes.rb to be,

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

Start the console,

$ 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

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).

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.

@kennyj kennyj added a commit to kennyj/rails that referenced this issue Feb 21, 2012
@kennyj kennyj Testcase for GH #5114. f5e69fc
@kennyj
kennyj commented Feb 21, 2012

I can reproduct it and realize the cause of problem.
It seems that this issue is journey's one.
I'll send PR to journey.

/cc @tenderlove

@kennyj
kennyj commented Feb 22, 2012

and I sent the testcase PR for this issue.

#5119

BTW, the PR for journey was merged to master and 1-0-stable :-)

@kennyj
kennyj commented Feb 22, 2012

@tomlanning

Please test my fix :)
Maybe, you can test it , if you add the below line in Gemfile (and bundle update).

gem 'journey', :git => "git://github.com/rails/journey", :branch => "1-0-stable"

@tomlanning

@kennyj

I added the explicit line to my Gemfile and it behaves correctly, as it did in 3.1. Thank-you for the quick turnaround!

@kennyj
kennyj commented Feb 22, 2012

@tomlanning

It will be fixed in the next version.
I'm closing this issue.

Thanks!

@kennyj kennyj closed this Feb 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment