Skip to content

Commit

Permalink
Use tablet constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mileusna committed Sep 12, 2024
1 parent 9ddd585 commit 343162a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ua.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const (
Version = "Version"
Mobile = "Mobile"
Tablet = "Tablet"

tablet = "tablet"
)

// Parse user agent string returning UserAgent struct
Expand All @@ -95,7 +97,7 @@ func Parse(userAgent string) UserAgent {
ua.OS = Android
var osIndex int
osIndex, ua.OSVersion = tokens.getIndexValue(Android)
ua.Tablet = strings.Contains(strings.ToLower(ua.String), strings.ToLower(Tablet))
ua.Tablet = strings.Contains(strings.ToLower(ua.String), tablet)
ua.Device = tokens.findAndroidDevice(osIndex)

case tokens.exists("iPhone"):
Expand Down Expand Up @@ -672,7 +674,7 @@ func (p *properties) findAndroidDevice(startIndex int) string {
case Chrome, Firefox, Safari, OperaMini, "Presto", Version, Mobile, MobileSafari, Mozilla, "AppleWebKit", WindowsNT, WindowsPhoneOS, Android, "Macintosh", Linux, CrOS:
// ignore these tokens, not device names
default:
if strings.Contains(strings.ToLower(dev), strings.ToLower(Tablet)) {
if strings.Contains(strings.ToLower(dev), tablet) {
p.list[i+1].Key = Tablet // leave Tablet tag for later table detection
} else {
p.list = append(p.list[:i+1], p.list[i+2:]...)
Expand Down

0 comments on commit 343162a

Please sign in to comment.