Skip to content

Instantly share code, notes, and snippets.

@no6v
Created February 17, 2010 03:05
Show Gist options
  • Save no6v/306243 to your computer and use it in GitHub Desktop.
Save no6v/306243 to your computer and use it in GitHub Desktop.
diff --git a/lib/plugins/expand-tinyurl.rb b/lib/plugins/expand-tinyurl.rb
index 15368a8..4ab563d 100644
--- a/lib/plugins/expand-tinyurl.rb
+++ b/lib/plugins/expand-tinyurl.rb
@@ -40,8 +40,9 @@ def expand_url(host, path)
h.get(path, { 'User-Agent' => 'Mozilla' })
end
return nil unless res.code == "301" or res.code == "302"
- newurl = res['Location']
- newurl.force_encoding(Encoding::UTF_8) if newurl.respond_to?(:force_encoding)
+ res['Location'].tap do |newurl|
+ newurl.force_encoding(Encoding::UTF_8) if newurl.respond_to?(:force_encoding)
+ end
rescue Exception => e
Termtter::Client.handle_error(e)
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment