HTML::ResolveLink update

miyagawa on 2006-09-27T19:18:02

HTML::ResolveLink is a module of mine to resolve any relative links found in (X)HTML to the absolute URI.

Here's how to use the module:

use HTML::ResolveLink;

my $resolver = HTML::ResolveLink->new( base => 'http://www.example.com/foo/bar.html', ); $html = $resolver->resolve($html);


Pretty simple.

This module is particularly useful when you deal with stuff like content in the RSS feeds. Some (bad) RSS feeds contain full content in content:encoded, atom:content or xhtml:body but the links there might be relative, not absolute.

In that case you can use this module to make them absolute URI, using entry's permalink as a base parameter to the module. Plagger has a wrapper plugin Filter::ResolveLink that uses exact this module.

Today I updated the module to accept 'callback' parameter that'd be called each time the module finds URL to resolve. That'll be pretty useful when you want to track how many URLs this module resolved, etc.

Go get from your near CPAN, or check out from SVN http://svn.bulknews.net/repos/public/HTML-ResolveLink/trunk>.
Also, I released Template::Plugin::ResolveLink which is a mere wrapper for the module to be used in TT templates. It'll be live on in a few hours.