@@ -57,7 +57,7 @@ module Agents |
||
| 57 | 57 |
|
| 58 | 58 |
def generate_uri(params = nil) |
| 59 | 59 |
uri = URI options[:post_url] |
| 60 |
- uri.query = URI.encode_www_form(Hash[URI.decode_www_form(uri.query)].merge(params)) if params |
|
| 60 |
+ uri.query = URI.encode_www_form(Hash[URI.decode_www_form(uri.query || '')].merge(params)) if params |
|
| 61 | 61 |
uri |
| 62 | 62 |
end |
| 63 | 63 |
|
@@ -152,6 +152,12 @@ describe Agents::PostAgent do |
||
| 152 | 152 |
uri.request_uri.should == "/a/path?existing_param=existing_value&some_param=some_value&another_param=another_value" |
| 153 | 153 |
end |
| 154 | 154 |
|
| 155 |
+ it "works fine with urls that do not have a query" do |
|
| 156 |
+ @checker.options['post_url'] = "http://example.com/a/path" |
|
| 157 |
+ uri = @checker.generate_uri("some_param" => "some_value", "another_param" => "another_value")
|
|
| 158 |
+ uri.request_uri.should == "/a/path?some_param=some_value&another_param=another_value" |
|
| 159 |
+ end |
|
| 160 |
+ |
|
| 155 | 161 |
it "just returns the post_uri when no params are given" do |
| 156 | 162 |
@checker.options['post_url'] = "http://example.com/a/path?existing_param=existing_value" |
| 157 | 163 |
uri = @checker.generate_uri |