Class: FacebookWall::FeedEntryFilters::LinkRewriter

Inherits:
FeedEntryFilter show all
Defined in:
lib/facebook_wall/feed_entry_filters/link_rewriter.rb

Overview

Completely rewrites HTML links in items, removing superfluous attributes added by Facebook. For example, example.com would be replaced with: example.com

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