File Coverage

blib/lib/URI/Find/UTF8.pm
Criterion Covered Total %
statement 22 23 95.6
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package URI::Find::UTF8;
2              
3 2     2   22342 use strict;
  2         4  
  2         81  
4 2     2   25 use 5.8.1;
  2         8  
  2         128  
5             our $VERSION = '0.04';
6              
7 2     2   10 use base qw( URI::Find );
  2         23  
  2         2201  
8 2     2   22729 use URI::Escape;
  2         5  
  2         471  
9              
10             sub uri_re {
11 43 50   43 1 211270 @_ == 1 || __PACKAGE__->badinvo;
12 43         90 my $self = shift;
13 43         180 my $x = sprintf '%s:/{0,2}[%s]+/[%s]*|%s',
14             $URI::scheme_re,
15             'A-Za-z0-9\-\.', # Domain part ... don't care about IDN yet
16             $self->uric_set . '\w#', # \w will have all 'word' characters in UTF8 semantics
17             $self->SUPER::uri_re; # Make this less priority
18 43         1292 return $x;
19             }
20              
21             sub _is_uri {
22 36 50   36   14633 @_ == 2 || __PACKAGE__->badinvo;
23              
24             # crufty: URI escape $$r_uri_cand so we get encoded URI.
25 36         67 my($self, $r_uri_cand) = @_;
26 36         66 my $uri_cand = $$r_uri_cand;
27              
28 36         94 my $uric_set = $self->uric_set;
29 36         313 $uri_cand =~ s{ ([^$uric_set/<>#]+) }{ URI::Escape::uri_escape_utf8($1) }xeg;
  0         0  
30              
31 36         227 return $self->SUPER::_is_uri(\$uri_cand);
32             }
33              
34             1;
35             __END__