File Coverage

blib/lib/Duadua/Parser/Browser/GoogleChrome.pm
Criterion Covered Total %
statement 27 27 100.0
branch 19 22 86.3
condition 15 18 83.3
subroutine 4 4 100.0
pod 1 1 100.0
total 66 72 91.6


line stmt bran cond sub pod time code
1             package Duadua::Parser::Browser::GoogleChrome;
2 6     6   1066 use strict;
  6         12  
  6         179  
3 6     6   30 use warnings;
  6         10  
  6         132  
4 6     6   28 use Duadua::Util;
  6         13  
  6         2649  
5              
6             sub try {
7 406     406 1 861 my ($class, $d) = @_;
8              
9 406 100       749 return if index($d->ua, 'http') > -1;
10 243 100       564 return if index($d->ua, 'oogle') > -1;
11 223 100 100     473 return if index($d->ua, ' OPR/') > -1 || index($d->ua, ' Vivaldi/') > -1;
12 219 100       523 return if index($d->ua, 'Browser/') > -1;
13 199 100       744 return if index($d->ua, 'QtWebEngine') > -1;
14              
15 197 50 66     407 if ( index($d->ua, 'Chrome/') > -1 && index($d->ua, 'AppleWebKit/') > -1 && index($d->ua, 'Safari/') > -1 ) {
      66        
16 4         13 my $h = {
17             name => 'Google Chrome',
18             };
19              
20 4 100       13 if ($d->opt_version) {
21 2         7 my ($version) = ($d->ua =~ m!Chrome/([\d.]+)!);
22 2 50       12 $h->{version} = $version if $version;
23             }
24              
25 4         17 return Duadua::Util->set_os($d, $h);
26             }
27              
28 193 100 100     454 if ( index($d->ua, 'Mozilla/') > -1 && index($d->ua, 'AppleWebKit/') > -1
      66        
      100        
29             && (index($d->ua, 'CrMo/') > -1 || index($d->ua, 'CriOS/') > -1) ) {
30 2         8 my $h = {
31             name => 'Google Chrome',
32             };
33              
34 2 100       7 if ($d->opt_version) {
35 1         9 my ($version) = ($d->ua =~ m!Cr(?:Mo|iOS)/([\d.]+)!);
36 1 50       8 $h->{version} = $version if $version;
37             }
38              
39 2         7 return Duadua::Util->set_os($d, $h);
40             }
41             }
42              
43             1;
44              
45             __END__