| 1 | package URI::Find::UTF8::ExtraCharacters; | ||||||||||||
| 2 | 7 | $URI::Find::UTF8::ExtraCharacters::VERSION = '0.03'; | |||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 7 | ▶ | use base 'URI::Find::UTF8'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | =head1 NAME | ||||||||||||
| 8 | |||||||||||||
| 9 | URI::Find::UTF8::ExtraCharacters - URI::Find::UTF8 with optional extra characters. | ||||||||||||
| 10 | |||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||
| 12 | |||||||||||||
| 13 | my $finder = URI::Find::UTF8::ExtraCharacters->new( sub { | ||||||||||||
| 14 | my ( $uri_obj, $url ) = @_; | ||||||||||||
| 15 | return "$uri_obj"; | ||||||||||||
| 16 | }, | ||||||||||||
| 17 | extra_characters => ['|'], | ||||||||||||
| 18 | ); | ||||||||||||
| 19 | my $text = "link to zombo: http://zombo.com/lorem|ipsum?queryparam=queryval"; | ||||||||||||
| 20 | $finder->find(\$text); | ||||||||||||
| 21 | say $text; #link to zombo: http://zombo.com/lorem%7Cipsum?queryparam=queryval | ||||||||||||
| 22 | |||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||
| 24 | |||||||||||||
| 25 | The web is a wacky place full of screwed up URLs. This is a drop in replacement for L<URI::Find::UTF8> | ||||||||||||
| 26 | ( Which is a drop in replacement for L<URI::Find> ) which allows you to pass in additional characters that | ||||||||||||
| 27 | URI::Find thinks are bogus. ( like '|' ) | ||||||||||||
| 28 | |||||||||||||
| 29 | =head2 Public Methods | ||||||||||||
| 30 | |||||||||||||
| 31 | =over 4 | ||||||||||||
| 32 | |||||||||||||
| 33 | =item B<new> | ||||||||||||
| 34 | |||||||||||||
| 35 | my $finder = URI::Find::UTF8::ExtraCharacters->new(\&callback, | ||||||||||||
| 36 | extra_characters => \@chars ); | ||||||||||||
| 37 | |||||||||||||
| 38 | Creates a new URI::Find::UTF8::ExtraCharacters object. See the docs for L<URI::Find> for more in depth documentation. | ||||||||||||
| 39 | |||||||||||||
| 40 | =back | ||||||||||||
| 41 | |||||||||||||
| 42 | =cut | ||||||||||||
| 43 | |||||||||||||
| 44 | 72 | ▶ | sub uric_set { | ||||||||||
|
Subroutine
uric_set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 45 | 72 | my $self = shift; | |||||||||||
| 46 | 72 | join('', map { quotemeta($_) } @{ $self->{_extra_characters} } ) | |||||||||||
| 47 | . $self->SUPER::uric_set; | ||||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 19 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 51 | 19 | my($class,$callback,%params) = @_; | |||||||||||
| 52 | 19 | ▶ | my $extra_characters = $params{extra_characters} || []; | ||||||||||
|
Condition100%2/2
$params{'extra_characters'} || []
MC/DC100%1/1
$params{'extra_characters'} || []
$params{'extra_characters'}
Truth table100%2/2
A
A= $params{'extra_characters'}
| |||||||||||||
| 53 | 19 | my $self = $class->SUPER::new($callback); | |||||||||||
| 54 | 19 | $self->{_extra_characters} = $extra_characters; | |||||||||||
| 55 | 19 | return $self; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | =head1 INCOMPATIBILITIES | ||||||||||||
| 59 | |||||||||||||
| 60 | This module does not export 'find_uris,' which L<URI::Find> does but L<URI::Find::UTF8> does not. | ||||||||||||
| 61 | |||||||||||||
| 62 | =head1 AUTHOR | ||||||||||||
| 63 | |||||||||||||
| 64 | Samuel Kaufman, skaufman-at-cpan.org | ||||||||||||
| 65 | |||||||||||||
| 66 | =head1 LICENSE | ||||||||||||
| 67 | |||||||||||||
| 68 | Copyright 2014 by Samuel Kaufman | ||||||||||||
| 69 | |||||||||||||
| 70 | This program is free software; you can redistribute it and/or | ||||||||||||
| 71 | modify it under the same terms as Perl itself. | ||||||||||||
| 72 | |||||||||||||
| 73 | See L<http://www.perlfoundation.org/artistic_license_1_0> | ||||||||||||
| 74 | |||||||||||||
| 75 | |||||||||||||
| 76 | =cut | ||||||||||||
| 77 | |||||||||||||
| 78 | 7 | 1; | |||||||||||