diff options
author | Claire McQuin <mcquin@users.noreply.github.com> | 2014-06-09 15:30:48 -0700 |
---|---|---|
committer | Claire McQuin <mcquin@users.noreply.github.com> | 2014-06-09 15:30:48 -0700 |
commit | fe38908f9a5e92730c8bf3898e6ab822afd787e9 (patch) | |
tree | 613e6781be5340fc1fc7f74f4117e02de0af5a1b /lib/chef/http.rb | |
parent | 8959420891b89ad33e8e9a010bed613b5f1cfae0 (diff) | |
parent | c84b5a23a17a19eba57cb5d62eb4f4e549eda35e (diff) | |
download | chef-fe38908f9a5e92730c8bf3898e6ab822afd787e9.tar.gz |
Merge pull request #1396 from svanharmelen/CHEF-5261
CHEF-5261 Added some tests to prevent double slashes
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r-- | lib/chef/http.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index e73e8e5549..7af1dc2aec 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -207,7 +207,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 |