Ask A Question

Notifications

You’re not receiving notifications from this thread.

FAO: Chris... URL Errors on pretty much any Rails site

Alan Reid asked in Rails

Hi I've come across a really weird bug, not just in my project but on quite a few rails sites.

https://gorails.com/users/sign_in?redirect_to=%2F - works fine
https://gorails.com/users/SIGN_IN?redirect_to=%2F - Errors

Both URL's are basically the same. However they are actually quite different

This site provides one work around...
http://gehling.dk/2010/02/how-to-make-rails-routing-case-insensitive/

Reply

Right. There's no official requirement to make URIs case insenstive.

Domains themselves are always downcased as it's part of the RFC but it is up to your web server to handle case sensitivity for the rest of the URL. It sounds like the rest of the URL should be case sensitive according to a more recent RFC.

http://stackoverflow.com/questions/15641694/are-uris-case-insensitive


That said, I've never had a situation where case in URLs mattered. Since users basically never type URLs, this is a super rare case that almost never comes up unless you're fiddling around in development.

If you do need that, looks like that middleware would work. You could also possibly do a rewrite in Nginx or Apache in order to downcase, which would be faster, but I'm not sure if it supports that type of thing. Usually rewrites are for changing the domain or URL entirely.

Reply

^ is generally my thought as well.

Never had a need for it to be case sensitive, I feel like it only happens when you are handing direct links to users, in which case you probably want to just let them type in lower case anyways because its easier.

i.e: go to mysite.example.com/sign_up to sign up or something. Which you could easily do a redirect route if needed as well.

Reply

My point is that while the W3 Spec states that mixed case is how it should be, but this is the first time I have experienced an issue with mixed case URL's. - I can understand the need for them, but for pure usability it is a pain.

I only found this because I had my caps lock button on by accident. There are many cases where users could type a URL, for example a promo page for a site. I think I am just trying to cover all eventualities to remove potential user error. ;)

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,140+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.