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   71 use strict;
  6         13  
  6         178  
3 6     6   30 use warnings;
  6         11  
  6         146  
4 6     6   42 use Duadua::Util;
  6         12  
  6         2671  
5              
6             sub try {
7 405     405 1 896 my ($class, $d) = @_;
8              
9 405 100       833 return if index($d->ua, 'http') > -1;
10 242 100       552 return if index($d->ua, 'oogle') > -1;
11 222 100 100     483 return if index($d->ua, ' OPR/') > -1 || index($d->ua, ' Vivaldi/') > -1;
12 218 100       506 return if index($d->ua, 'Browser/') > -1;
13 198 100       425 return if index($d->ua, 'QtWebEngine') > -1;
14              
15 196 50 66     420 if ( index($d->ua, 'Chrome/') > -1 && index($d->ua, 'AppleWebKit/') > -1 && index($d->ua, 'Safari/') > -1 ) {
      66        
16 4         12 my $h = {
17             name => 'Google Chrome',
18             };
19              
20 4 100       10 if ($d->opt_version) {
21 2         5 my ($version) = ($d->ua =~ m!Chrome/([\d.]+)!);
22 2 50       10 $h->{version} = $version if $version;
23             }
24              
25 4         16 return Duadua::Util->set_os($d, $h);
26             }
27              
28 192 100 100     441 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       9 if ($d->opt_version) {
35 1         4 my ($version) = ($d->ua =~ m!Cr(?:Mo|iOS)/([\d.]+)!);
36 1 50       6 $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__