tylerhunt/rack-canonical-host — pull request #19 by jcarbo (2014-04-15 21:19:45+00:00)
Title: Add :scheme option for ensuring http(s)

I ran into a use-case where I needed to redirect the following to the
(https://www) version of the url:
http://example.com
https://example.com
http://www.example.com
https://www.example.com

In the first case this would take two redirects, which is not the
end of the world. However, I figured since I was already using this
gem I'd check for an option I could pass that would ensure the
desired URI scheme while it was ensuring the desired host. Since there
wasn't one, I built it out (including specs). It's a very minor option
and is backwards compatible (doesn't force a redirect if the option
is missing, malformed, or if scheme is already correct). It does toe
the line of the single responsibility principle, but I think it makes
a great deal of sense to check both the scheme and host in one shot.