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   3017 use strict;
  8         13  
  8         175  
4 8     8   26 use warnings;
  8         8  
  8         146  
5              
6 8     8   21 use Carp;
  8         9  
  8         335  
7              
8 8     8   31 use parent qw/Enbld::Target::AttributeExtension::Word/;
  8         86  
  8         44  
9              
10             sub validate {
11 208     208 0 209 my ( $self, $string ) = @_;
12              
13 208         446 $self->SUPER::validate( $string );
14              
15 196         208 my $pattern = q{s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+};
16              
17 196 100       1653 if ( $string !~ /^$pattern$/ ) {
18 4         8 my $type = ref( $self );
19 4         14 $type =~ s/.*:://;
20 4         18 require Enbld::Exception;
21 4         18 croak( Enbld::Exception->new(
22             "Attribute '$type' isn't valid URL string", $string
23             ));
24             }
25             }
26              
27             1;
28