diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..8bb43a1 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +ssl_requirement diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..5dcf256 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-1.9.3-p0 diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index be7c18d..0000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm use ruby-1.9.3-p0@ssl_requirement --create diff --git a/lib/ssl_requirement.rb b/lib/ssl_requirement.rb index aaa08e8..203e5c7 100644 --- a/lib/ssl_requirement.rb +++ b/lib/ssl_requirement.rb @@ -28,8 +28,11 @@ module SslRequirement :disable_ssl_check mattr_accessor :redirect_status + self.ssl_host = nil + self.non_ssl_host = nil + def self.ssl_host - determine_host(@@ssl_host) rescue nil + determine_host(@@ssl_host) end def self.ssl_port @@ -37,7 +40,7 @@ def self.ssl_port end def self.non_ssl_host - determine_host(@@non_ssl_host) rescue nil + determine_host(@@non_ssl_host) end def self.non_ssl_port diff --git a/lib/url_for.rb b/lib/url_for.rb index 3d8d3bf..11f264b 100644 --- a/lib/url_for.rb +++ b/lib/url_for.rb @@ -6,7 +6,7 @@ module Routing class RouteSet # Add a secure option to the rewrite method. - def url_for_with_secure_option(options = {}) + def url_for_with_secure_option(options = {}, route_name = nil, url_strategy = UNKNOWN) secure = options.delete(:secure) # if secure && ssl check is not disabled, convert to full url with https @@ -30,18 +30,18 @@ def url_for_with_secure_option(options = {}) end end - url_for_without_secure_option(options) + url_for_without_secure_option(options, route_name, url_strategy) end # if full URL is requested for http and we've been told to use a # non-ssl host override, then use it - def url_for_with_non_ssl_host(options) + def url_for_with_non_ssl_host(options, route_name = nil, url_strategy = UNKNOWN) if !options[:only_path] && !SslRequirement.non_ssl_host.nil? if !(/^https/ =~ (options[:protocol] || @request.try(:protocol))) options.merge! :host => SslRequirement.non_ssl_host end end - url_for_without_non_ssl_host(options) + url_for_without_non_ssl_host(options, route_name, url_strategy) end # want with_secure_option to get run first (so chain it last)