Skip to content

Commit

Permalink
fix potential empty body, preventing double call of to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
bo-oz committed Apr 12, 2018
1 parent bf6c11a commit f653625
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/vimeo_me2/http/http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ def set_auth_header token
end

def http_request
body = @body.to_json if @headers['Content-Type'] == 'application/json'
body = json_header? ? @body.to_json : @body

return {headers:@headers, body:body, query:@query}
end

def json_header?
@headers['Content-Type'] == 'application/json'
end

def prefix_endpoint endpoint
/https?/.match(endpoint) ? endpoint : "https://api.vimeo.com#{endpoint}"
end
Expand Down

0 comments on commit f653625

Please sign in to comment.