@@ -171,7 +171,7 @@ func Parse(userAgent string) UserAgent {
171
171
ua .Name = Firefox
172
172
ua .Version = tokens .get (Firefox )
173
173
ua .Mobile = tokens .exists ("Mobile" )
174
- ua .Tablet = strings . Contains ( strings . ToLower ( ua . String ), "tablet " )
174
+ ua .Tablet = tokens . exists ( "Tablet " )
175
175
176
176
case tokens .get ("Vivaldi" ) != "" :
177
177
ua .Name = Vivaldi
@@ -489,6 +489,15 @@ func (p properties) exists(key string) bool {
489
489
return false
490
490
}
491
491
492
+ // func (p properties) existsIgnoreCase(key string) bool {
493
+ // for _, prop := range p.list {
494
+ // if strings.EqualFold(prop.Key, key) {
495
+ // return true
496
+ // }
497
+ // }
498
+ // return false
499
+ // }
500
+
492
501
func (p properties ) existsAny (keys ... string ) bool {
493
502
for _ , k := range keys {
494
503
for _ , prop := range p .list {
@@ -548,7 +557,7 @@ func (p properties) findBestMatch(withVerOnly bool) string {
548
557
for i := 0 ; i < n ; i ++ {
549
558
for _ , prop := range p .list {
550
559
switch prop .Key {
551
- case Chrome , Firefox , Safari , "Version" , "Mobile" , "Mobile Safari" , "Mozilla" , "AppleWebKit" , "Windows NT" , "Windows Phone OS" , Android , "Macintosh" , Linux , "GSA" , "CrOS" :
560
+ case Chrome , Firefox , Safari , "Version" , "Mobile" , "Mobile Safari" , "Mozilla" , "AppleWebKit" , "Windows NT" , "Windows Phone OS" , Android , "Macintosh" , Linux , "GSA" , "CrOS" , "Tablet" :
552
561
default :
553
562
// don' pick if starts with number
554
563
if len (prop .Key ) != 0 && prop .Key [0 ] >= 48 && prop .Key [0 ] <= 57 {
@@ -589,7 +598,11 @@ func (p *properties) findAndroidDevice(startIndex int) string {
589
598
case Chrome , Firefox , Safari , "Opera Mini" , "Presto" , "Version" , "Mobile" , "Mobile Safari" , "Mozilla" , "AppleWebKit" , "Windows NT" , "Windows Phone OS" , Android , "Macintosh" , Linux , "CrOS" :
590
599
// ignore this tokens, not device names
591
600
default :
592
- p .list = append (p .list [:i + 1 ], p .list [i + 2 :]... )
601
+ if strings .Contains (strings .ToLower (dev ), "tablet" ) {
602
+ p .list [i + 1 ].Key = "Tablet" // leave Tablet tag for later table detection
603
+ } else {
604
+ p .list = append (p .list [:i + 1 ], p .list [i + 2 :]... )
605
+ }
593
606
return strings .TrimSpace (strings .TrimSuffix (dev , "Build" ))
594
607
}
595
608
}
0 commit comments