Skip to content

Commit

Permalink
add support for macOS Big Sur (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snawoot authored May 1, 2024
1 parent ae0c131 commit d3355ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Unknown version is returned as `0`.

#### OS Version

OS X major version is alway 10 with consecutive minor versions indicating release releases (10 - Yosemite, 11 - El Capitain, 12 Sierra, etc). Windows version is NT version. `Version{0, 0, 0}` indicated version is unknown or not evaluated.
OS X major version is always 10 for releases prior to Big Sur with consecutive minor versions indicating release releases (10 - Yosemite, 11 - El Capitain, 12 Sierra, etc). macOS Big Sur is indicated as `{11, 1, 0}`. Windows version is NT version. `Version{0, 0, 0}` indicated version is unknown or not evaluated.
Versions can be compared using `Less` function: `if ver1.Less(ver2) {}`

Here are some examples across the platform, os.name, and os.version:
Expand Down
2 changes: 1 addition & 1 deletion system.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (u *UserAgent) evalWindows(ua string) {

func (u *UserAgent) evalMacintosh(uaPlatformGroup string) {
u.OS.Platform = PlatformMac
if i := strings.Index(uaPlatformGroup, "os x 10"); i != -1 {
if i := strings.Index(uaPlatformGroup, "os x "); i != -1 {
u.OS.Name = OSMacOSX
u.OS.Version.parse(uaPlatformGroup[i+5:])

Expand Down
4 changes: 4 additions & 0 deletions uasurfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ var testUAVars = []struct {
UserAgent{
Browser{BrowserSafari, Version{10, 0, 0}}, OS{PlatformMac, OSMacOSX, Version{10, 12, 0}}, DeviceComputer}},

{"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36", // macOS Big Sur
UserAgent{
Browser{BrowserChrome, Version{87, 0, 4280}}, OS{PlatformMac, OSMacOSX, Version{11, 1, 0}}, DeviceComputer}},

// Firefox
{"Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12F69 Safari/600.1.4",
UserAgent{
Expand Down

0 comments on commit d3355ce

Please sign in to comment.