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   35 use strict;
  6         11  
  6         154  
3 6     6   27 use warnings;
  6         8  
  6         128  
4 6     6   25 use Duadua::Util;
  6         12  
  6         2332  
5              
6             sub try {
7 405     405 1 816 my ($class, $d) = @_;
8              
9 405 100       751 return if index($d->ua, 'http') > -1;
10 242 100       551 return if index($d->ua, 'oogle') > -1;
11 222 100 100     4369 return if index($d->ua, ' OPR/') > -1 || index($d->ua, ' Vivaldi/') > -1;
12 218 100       504 return if index($d->ua, 'Browser/') > -1;
13 198 100       440 return if index($d->ua, 'QtWebEngine') > -1;
14              
15 196 50 66     437 if ( index($d->ua, 'Chrome/') > -1 && index($d->ua, 'AppleWebKit/') > -1 && index($d->ua, 'Safari/') > -1 ) {
      66        
16 4         10 my $h = {
17             name => 'Google Chrome',
18             };
19              
20 4 100       20 if ($d->opt_version) {
21 2         6 my ($version) = ($d->ua =~ m!Chrome/([\d.]+)!);
22 2 50       9 $h->{version} = $version if $version;
23             }
24              
25 4         11 return Duadua::Util->set_os($d, $h);
26             }
27              
28 192 100 100     428 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         6 my $h = {
31             name => 'Google Chrome',
32             };
33              
34 2 100       6 if ($d->opt_version) {
35 1         6 my ($version) = ($d->ua =~ m!Cr(?:Mo|iOS)/([\d.]+)!);
36 1 50       7 $h->{version} = $version if $version;
37             }
38              
39 2         10 return Duadua::Util->set_os($d, $h);
40             }
41             }
42              
43             1;
44              
45             __END__