1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

support non-strings in url concatination

This commit is contained in:
Adam Wiggins 2008-06-20 20:31:17 -07:00
parent f87af3f7e5
commit c7b31306b3
2 changed files with 5 additions and 1 deletions

View file

@ -92,7 +92,7 @@ module RestClient
def concat_urls(url, suburl) # :nodoc:
if url.slice(-1, 1) == '/' or suburl.slice(0, 1) == '/'
url + suburl
"#{url}#{suburl}"
else
"#{url}/#{suburl}"
end

View file

@ -41,6 +41,10 @@ describe RestClient::Resource do
@resource.concat_urls('http://example.com', '/resource').should == 'http://example.com/resource'
end
it "concatinates even non-string urls (i.e. 'posts' + 1)" do
@resource.concat_urls('posts/', 1).should == 'posts/1'
end
it "offers subresources via []" do
parent = RestClient::Resource.new('http://example.com')
parent['posts'].url.should == 'http://example.com/posts'