File Coverage

blib/lib/OpenID/Lite/RelyingParty/Discover/Fetcher/Yadis/HTMLExtractor.pm
Criterion Covered Total %
statement 9 17 52.9
branch 0 2 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 0 1 0.0
total 12 28 42.8


line stmt bran cond sub pod time code
1             package OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis::HTMLExtractor;
2              
3 1     1   7 use HTML::TreeBuilder::XPath;
  1         3  
  1         14  
4 1     1   28 use URI::Escape ();
  1         3  
  1         22  
5 1     1   6 use OpenID::Lite::Constants::Yadis qw(XRDS_HEADER YADIS_HEADER);
  1         3  
  1         232  
6              
7             sub extract {
8 0     0 0   my ( $class, $content ) = @_;
9              
10 0           my $tree = HTML::TreeBuilder::XPath->new;
11 0           $tree->parse(lc $content);
12 0   0       my $location
13             = $tree->findvalue( $class->_build_xpath_with( XRDS_HEADER ) )
14             || $tree->findvalue( $class->_build_xpath_with( YADIS_HEADER ) );
15 0 0         return unless $location;
16 0           return URI::Escape::uri_unescape($location);
17             }
18              
19             sub _build_xpath_with {
20 0     0     my ( $class, $header ) = @_;
21 0           return sprintf(q{/html/head/meta[@http-equiv='%s']/@content}, lc $header)
22             }
23              
24             1;
25