Skip to content

Commit

Permalink
TinyURL: return the complete url if the TinyURL service fails
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter committed Sep 25, 2008
1 parent bd5005a commit fe3bf92
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/support/tinyurl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ class TinyURL
def self.tiny(url)
return nil unless url
http = Net::HTTP.start("tinyurl.com", 80)
response = http.post("/create.php", "url=#{url}")
begin
response = http.post("/create.php", "url=#{url}")
rescue Exception => e
return url
end

if response.code == "200"
body = response.read_body
Expand Down

0 comments on commit fe3bf92

Please sign in to comment.