end
Rails.configuration.Login.TrustedClients.keys.each do |url|
- if norm_url_prefix == norm(url)
+ trusted = norm(url)
+ if norm_url_prefix == trusted
+ return true
+ end
+ if trusted.host.to_s.starts_with?("*.") &&
+ norm_url_prefix.to_s.starts_with?(trusted.scheme + "://") &&
+ norm_url_prefix.to_s.ends_with?(trusted.to_s[trusted.scheme.length + 4...])
return true
end
end
def norm url
# normalize URL for comparison
url = URI(url.to_s)
- if url.scheme == "https"
- url.port == "443"
- end
- if url.scheme == "http"
- url.port == "80"
+ if url.scheme == "https" && url.port == ""
+ url.port = "443"
+ elsif url.scheme == "http" && url.port == ""
+ url.port = "80"
end
url.path = "/"
+ url.query = nil
+ url.fragment = nil
url
end
end