summaryrefslogtreecommitdiff
path: root/lib/chef/http.rb
diff options
context:
space:
mode:
authorSander van Harmelen <svanharmelen@schubergphilis.com>2014-05-01 01:02:10 +0200
committerSander van Harmelen <svanharmelen@schubergphilis.com>2014-05-13 09:40:25 +0200
commitc84b5a23a17a19eba57cb5d62eb4f4e549eda35e (patch)
treee9b4d74f52030327e413d038955fb47d51f391ac /lib/chef/http.rb
parentb7ef4738811d9bc77d004c690115b234b4e88ea2 (diff)
downloadchef-c84b5a23a17a19eba57cb5d62eb4f4e549eda35e.tar.gz
COOK-5261 Added some formatting to prevent malformed URLs
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r--lib/chef/http.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 42b5decd6b..44b418735f 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -204,7 +204,10 @@ class Chef
elsif path.nil? or path.empty?
URI.parse(@url)
else
- URI.parse("#{@url}/#{path}")
+ # The regular expressions used here are to make sure '@url' does not have
+ # any trailing slashes and 'path' does not have any leading slashes. This
+ # way they are always joined correctly using just one slash.
+ URI.parse(@url.gsub(%r{/+$}, '') + '/' + path.gsub(%r{^/+}, ''))
end
end