I have found myself needing to know what, if any, the subdomain is in a request… from within a Rack middleware. I’d like to redirect, change the path, or set the Current.locale based on that subdomain.
To my surprise every time, this doesn’t work.
For: https://en.wikipedia.org
Rack::Request.new(env).subdomain #=> 'en'
It’d be a lot cooler if it did.
Also, if this worked to handle multiple subdomains too.
I agree with @samsaffron. I understand why this is useful, but parsing domain names is Not Trivial ™ and would be better handled by an external library. We could figure out a way to add a method to the request object, but I think that would be better handled in the respective library.