Class: FacebookWall::FeedEntryFilters::LinkRewriter
- Inherits:
-
FeedEntryFilter
- Object
- FeedEntryFilter
- FacebookWall::FeedEntryFilters::LinkRewriter
- Defined in:
- lib/facebook_wall/feed_entry_filters/link_rewriter.rb
Overview
Completely rewrites HTML links in item
s, removing superfluous attributes added by Facebook. For example,
<a href="http://example.com" target="_blank" onmousedown="doSomething()" rel="nofollow" id="link">example.com</a>
would be replaced with:
<a href="http://example.com">example.com</a>
Instance Method Summary collapse
Instance Method Details
#apply!(feed_entry) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/facebook_wall/feed_entry_filters/link_rewriter.rb', line 8 def apply!(feed_entry) feed_entry.description.scan(/<a\s+[^>]+>/).each do |link_tag| href_matches = link_tag.match(/\s+(href="[^"]*")/) feed_entry.description.gsub! link_tag, "<a #{href_matches[1]}>" if href_matches end end |