File Coverage

blib/lib/Enbld/Target/AttributeExtension/URL.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Enbld::Target::AttributeExtension::URL;
2              
3 8     8   4054 use strict;
  8         17  
  8         407  
4 8     8   40 use warnings;
  8         14  
  8         206  
5              
6 8     8   43 use Carp;
  8         11  
  8         522  
7              
8 8     8   40 use parent qw/Enbld::Target::AttributeExtension::Word/;
  8         10  
  8         55  
9              
10             sub validate {
11 208     208 0 336 my ( $self, $string ) = @_;
12              
13 208         591 $self->SUPER::validate( $string );
14              
15 196         278 my $pattern = q{s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+};
16              
17 196 100       2019 if ( $string !~ /^$pattern$/ ) {
18 4         8 my $type = ref( $self );
19 4         17 $type =~ s/.*:://;
20 4         20 require Enbld::Exception;
21 4         25 croak( Enbld::Exception->new(
22             "Attribute '$type' isn't valid URL string", $string
23             ));
24             }
25             }
26              
27             1;
28