File Coverage

blib/lib/EasyDNS/DDNS/Util.pm
Criterion Covered Total %
statement 15 20 75.0
branch 2 8 25.0
condition n/a
subroutine 4 5 80.0
pod 0 3 0.0
total 21 36 58.3


line stmt bran cond sub pod time code
1             package EasyDNS::DDNS::Util;
2              
3 6     6   151602 use strict;
  6         11  
  6         214  
4 6     6   29 use warnings;
  6         25  
  6         2376  
5              
6             sub trim {
7 48     48 0 127 my ($s) = @_;
8 48 50       115 return '' if !defined $s;
9 48         114 $s =~ s/^\s+//;
10 48         95 $s =~ s/\s+$//;
11 48         111 return $s;
12             }
13              
14             sub redact_basic_auth_in_url {
15 3     3 0 145078 my ($url) = @_;
16 3 50       11 return '' if !defined $url;
17              
18             # Redact user:pass@ in URL authority.
19             # Examples:
20             # https://user:token@host/path -> https://user:***@host/path
21             # http://user:pass@host -> http://user:***@host
22 3         40 $url =~ s{(https?://)([^:/\@]+):([^@\s]+)\@}{$1$2:***@}ig;
23 3         15 return $url;
24             }
25              
26             sub redact_header_value {
27 0     0 0   my ($name, $value) = @_;
28 0 0         return $value if !defined $name;
29              
30 0           my $n = lc $name;
31 0 0         return '***' if $n eq 'authorization';
32 0           return $value;
33             }
34              
35             1;
36              
37             __END__