Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails root_url has two forward slashes when default_url_options trailing_slash is true

When this line is set in the application.rb file:

config.action_controller.default_url_options = { trailing_slash: true}

The root_url contains two forward slashes:

www.example.com//

Without that line we get:

www.example.com

The reason we have this is SEO purposes, the site was converted from php and we wanted to maintain consistency.

Question: Is there any way to remove the double forward slash? It only started doing this recently... maybe a recent change in Rails? (We always update to the latest.)

Update: Was able to reproduce with a default app. (Rails 3.2.8) https://github.com/silasj/rails_test_forward_slash

Gihub Issue: https://github.com/rails/rails/issues/8700

like image 202
silasjmatson Avatar asked Oct 21 '22 20:10

silasjmatson


1 Answers

This is a rails bug. I tracked it down and submitted a PR to solve the problem https://github.com/rails/rails/pull/8701

I think we can merge it in in the near future. I'll try to backport the patch to 3-2-stable so that it will be available in the next 3.2.x release.

EDIT: PR is merged into rails/master and rails/3-2-stable. Sadly a little to lait for 3.2.10, need to wait for the next release ;).

like image 70
Yves Senn Avatar answered Nov 03 '22 09:11

Yves Senn