Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Fix detection of Firefox on iPad
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Michel <[email protected]>
  • Loading branch information
nono committed Apr 27, 2020
1 parent 8ecdab5 commit 42e4a8f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Not yet published

- Fix detection of Firefox on iPad.

## 0.5.2

- Detect Electron. See [commit](https://github.com/mssola/user_agent/commit/1a36963d74c0efca7de80dc7518a0958c66b3c4f).
Expand Down
5 changes: 5 additions & 0 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ var uastrings = []struct {
ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/7.0.4 Mobile/16B91 Safari/605.1.15",
expected: "Mozilla:5.0 Platform:iPhone OS:CPU iPhone OS 12_1 like Mac OS X Browser:Firefox-7.0.4 Engine:AppleWebKit-605.1.15 Bot:false Mobile:true",
},
{
title: "Firefox on iPad",
ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/24.1 Safari/605.1.15",
expected: "Mozilla:5.0 Platform:iPad OS:Intel Mac OS X 10.15 Browser:Firefox-24.1 Engine:AppleWebKit-605.1.15 Bot:false Mobile:true",
},
{
title: "Electron",
ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) CozyDrive/3.17.0 Chrome/73.0.3683.119 Electron/5.0.0 Safari/537.36",
Expand Down
6 changes: 6 additions & 0 deletions operating_systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ func webkit(p *UserAgent, comment []string) {
}
}
}

// Special case for Firefox on iPad, where the platform is advertised as Macintosh instead of iPad
if p.platform == "Macintosh" && p.browser.Engine == "AppleWebKit" && p.browser.Name == "Firefox" {
p.platform = "iPad"
p.mobile = true
}
}

// Guess the OS, the localization and if this is a mobile device
Expand Down

0 comments on commit 42e4a8f

Please sign in to comment.