summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2014-11-28 12:16:51 +0000
committerJon Cowie <jcowie@etsy.com>2014-12-29 13:14:42 +0000
commit2339da8290061d975e06fc618b84999f260f458c (patch)
tree0edeaf4957c0cf2b022af2d97b7af0407da22070
parent151e18fc0ebf1597498a65008f02a760b1737ef0 (diff)
downloadchef-2339da8290061d975e06fc618b84999f260f458c.tar.gz
Fix. Make sure that scheme part of the URI is treated in a case-insensitive manner.
This is as per http://en.wikipedia.org/wiki/URI_scheme, and solves some edges i.e., following (30x) URL from the "Location" header where we have to deal with "HTTP://". Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r--lib/chef/http.rb2
-rw-r--r--spec/unit/http_spec.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 8d00a38dc1..5e52337aff 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -203,7 +203,7 @@ class Chef
def create_url(path)
return path if path.is_a?(URI)
- if path =~ /^(http|https):\/\//
+ if path =~ /^(http|https):\/\//i
URI.parse(path)
elsif path.nil? or path.empty?
URI.parse(@url)
diff --git a/spec/unit/http_spec.rb b/spec/unit/http_spec.rb
index 60d36eb4a0..ddfc56583d 100644
--- a/spec/unit/http_spec.rb
+++ b/spec/unit/http_spec.rb
@@ -44,6 +44,13 @@ describe Chef::HTTP do
expect(http.create_url('///api/endpoint?url=http://foo.bar')).to eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar'))
end
+ # As per: https://github.com/opscode/chef/issues/2500
+ it 'should treat scheme part of the URI in a case-insensitive manner' do
+ http = Chef::HTTP.allocate # Calling Chef::HTTP::new sets @url, don't want that.
+ expect { http.create_url('HTTP://www1.chef.io/') }.not_to raise_error
+ expect(http.create_url('HTTP://www2.chef.io/')).to eql(URI.parse('http://www2.chef.io/'))
+ end
+
end # create_url
describe "head" do