10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/secure_routes/mapper.rb', line 10
def match_with_secure path, options
if Rails.application.config.action_dispatch.secure_routes
options_ssl = options[:secure]
options_without_ssl = options.dup
options_without_ssl.delete(:as)
ssl = @scope[:secure] === true || options_ssl === true
no_ssl = @scope[:secure] === false || options_ssl === false
options.deep_merge! :constraints => { :protocol => 'https://' } if ssl
options.deep_merge! :constraints => { :protocol => 'http://' } if no_ssl
match_without_secure path, options
match_without_secure path, options_without_ssl.merge(:to => redirect {|p, req| req.url.gsub(/^http/, 'https') }) if ssl
match_without_secure path, options_without_ssl.merge(:to => redirect {|p, req| req.url.gsub(/^https/, 'http') }) if no_ssl
else
match_without_secure path, options
end
end
|