Unverified Commit c124869d authored by Dennis Schubert's avatar Dennis Schubert

Merge pull request #7010 from SuperTux88/refactor-pod-uri-parse

Use https for the pod_uri if require_ssl is true
parents 08c6d485 8d725160
......@@ -6,15 +6,16 @@ module Configuration
return @pod_uri.dup unless @pod_uri.nil?
url = environment.url.get
url = "http://#{url}" unless url =~ /^(https?:\/\/)/
url << "/" unless url.end_with?("/")
begin
@pod_uri = Addressable::URI.parse(url)
@pod_uri = Addressable::URI.heuristic_parse(url)
rescue
puts "WARNING: pod url #{url} is not a legal URI"
end
@pod_uri.scheme = "https" if environment.require_ssl?
@pod_uri.path = "/"
@pod_uri.dup
end
......
......@@ -12,6 +12,7 @@ describe Configuration::Methods do
describe "#pod_uri" do
before do
@settings.environment.url = nil
@settings.environment.require_ssl = false
@settings.instance_variable_set(:@pod_uri, nil)
end
......@@ -36,6 +37,18 @@ describe Configuration::Methods do
expect(@settings.pod_uri.to_s).to eq("http://example.org/")
end
it "adds https:// on the front if require_ssl is true" do
@settings.environment.require_ssl = true
@settings.environment.url = "example.org"
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
end
it "changes http to https if require_ssl is true" do
@settings.environment.require_ssl = true
@settings.environment.url = "http://example.org/"
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
end
it "does not add a prefix if there already is https:// on the front" do
@settings.environment.url = "https://example.org/"
expect(@settings.pod_uri.to_s).to eq("https://example.org/")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment