Permalink
Browse files

Still return full payload with :shorten => true

  • Loading branch information...
1 parent 28b25d6 commit f25aa47a436539fa78553406544d77b2ff9921f4 @ConradIrwin committed Nov 11, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/jist.rb
View
@@ -95,8 +95,9 @@ def multi_gist(files, options={})
if Net::HTTPSuccess === response
payload = on_success(response.body, options)
if options[:shorten]
- {'html_url' => shorten(payload['html_url'])}
+ payload['html_url'] = shorten(payload['html_url'])
end
+ payload
else
raise "Got #{response.class} from gist: #{response.body}"
end
@@ -110,16 +111,16 @@ def multi_gist(files, options={})
raise e.extend Error
end
- # Given a URL, shorten it
+ # Convert long github urls into shotr git.io ones
@dlo

dlo Nov 11, 2012

Contributor

NBD, but "shotr" -> "short"

#
- # Based on https://gist.github.com/1762136
+ # @param [String] url
+ # @return [String] shortened url, or long url if shortening fails
def shorten(url)
response = Net::HTTP.post_form(URI("http://git.io/"), :url => url)
case response.code
when "201"
response['Location']
else
- # If the shortener failed, just return the unshortened URL.
url
end
end

0 comments on commit f25aa47

Please sign in to comment.