File Coverage

blib/lib/URI/Find/UTF8.pm
Criterion Covered Total %
statement 21 22 95.4
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 30 33 90.9


line stmt bran cond sub pod time code
1             package URI::Find::UTF8;
2              
3 3     3   89688 use strict;
  3         23  
  3         73  
4 3     3   43 use 5.8.1;
  3         10  
5             our $VERSION = '0.05';
6              
7 3     3   25 use base qw( URI::Find );
  3         10  
  3         1644  
8 3     3   32353 use URI::Escape;
  3         7  
  3         690  
9              
10             sub uri_re {
11 45 50   45 1 304875 @_ == 1 || __PACKAGE__->badinvo;
12 45         123 my $self = shift;
13 45         169 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 45         927 return $x;
19             }
20              
21             sub _is_uri {
22 38 50   38   43478 @_ == 2 || __PACKAGE__->badinvo;
23              
24             # crufty: URI escape $$r_uri_cand so we get encoded URI.
25 38         88 my($self, $r_uri_cand) = @_;
26 38         82 my $uri_cand = $$r_uri_cand;
27              
28 38         112 my $uric_set = $self->uric_set;
29 38         373 $uri_cand =~ s{ ([^$uric_set/<>#]+) }{ URI::Escape::uri_escape_utf8($1) }xeg;
  0         0  
30              
31 38         373 return $self->SUPER::_is_uri(\$uri_cand);
32             }
33              
34             1;
35             __END__