FollowLinks/Filter/Strip.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 58 CC 6 SCAR 27.4
CC
6
Cov
0%
apply
30.0
new
6.0
BEGIN
2.0
CRAP 15.5
1 # $Id: /mirror/perl/GunghoX-FollowLinks/trunk/lib/GunghoX/FollowLinks/Filter/Strip.pm 40582 2008-01-29T13:53:00.542283Z daisuke $
2  
3 package GunghoX::FollowLinks::Filter::Strip;
4 use strict;
5 use warnings;
6 use base qw(GunghoX::FollowLinks::Filter);
7 use URI;
8  
9 my @fields = qw(strip_fragment strip_query strip_userinfo);
10 __PACKAGE__->mk_accessors($_) for @fields;
11  
12 sub new
13 {
14 my $class = shift;
15 my %args = @_;
16  
17 foreach my $key (@fields) {
18 $args{$key} = exists $args{$key} ? $args{$key} : 1;
19 }
20 $class->SUPER::new(%args);
21 }
22  
23 sub apply
24 {
25 my ($self, $c, $uri) = @_;
26  
27 $c->log->debug("[FILTER] Removing " .
28 join(', ',
29 map { $self->$_ ? "$_=YES" : "$_=NO" } @fields
30 )
31 );
32  
33 $uri->fragment(undef) if $uri->can('fragment') && $self->strip_fragment;
34 $uri->query(undef) if $uri->can('query') && $self->strip_query;
35 $uri->userinfo(undef) if $uri->can('userinfo') && $self->strip_userinfo;
36 }
37  
38 1;