Skip to content

Commit ac8d049

Browse files
committed
Fix the non-url-encoded key value bug in HTTP GET
1 parent efde69b commit ac8d049

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/jira/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def url
417417
if @attrs['self']
418418
@attrs['self']
419419
elsif key_value
420-
self.class.singular_path(client, key_value.to_s, prefix)
420+
self.class.singular_path(client, URI.encode(key_value.to_s), prefix)
421421
else
422422
self.class.collection_path(client, prefix)
423423
end

spec/jira/base_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ class JIRA::Resource::HasManyExample < JIRA::Base # :nodoc:
334334
attrs['id'] = '98765'
335335
subject.url.should == "/foo/bar/deadbeef/98765"
336336
end
337+
338+
it "generates the encoded URL from key value" do
339+
attrs['self'] = nil
340+
attrs['id'] = 'foo bar'
341+
subject.url.should == "/foo/bar/deadbeef/foo%20bar"
342+
end
337343

338344
it "generates the URL from collection_path if self and id not set" do
339345
attrs['self'] = nil

0 commit comments

Comments
 (0)