Created
November 22, 2011 14:51
-
-
Save jaspertandy/1385833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
Earthquake.init do | |
output_filter do |item| | |
next unless item['text'] | |
text = item["text"] | |
text.scan( /http:\/\/t\.co\/[a-zA-Z0-9\-]+/ ).each do |url| | |
uri = URI.parse url | |
Net::HTTP::start( uri.host , uri.port ) do |connection| | |
connection.request_get uri.path do |response| | |
text.gsub! url , response['Location'] | |
end | |
end | |
end | |
text | |
end | |
end |
https://gist.github.com/3187216
Fixed problem I was getting with empty String with some links.
@adamtomecek Thank's a lot for this!
This solved the issue :)
https://gist.github.com/Kjwon15/9657129
I fixed it doesn't applied for item object.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thx for this plugin, it's working great. However I encounter the same erroneous behavior with the latest version of your script.
You said you modified the core, that would be interesting to know what you modified.
Here's the stacktrace that appear in the console for reference: