Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssl_requirement
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-1.9.3-p0
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

7 changes: 5 additions & 2 deletions lib/ssl_requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ 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
@@ssl_port ||= 443
end

def self.non_ssl_host
determine_host(@@non_ssl_host) rescue nil
determine_host(@@non_ssl_host)
end

def self.non_ssl_port
Expand Down
8 changes: 4 additions & 4 deletions lib/url_for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down