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

Commit

Permalink
Merge pull request #70 from DanMHammer/master
Browse files Browse the repository at this point in the history
Added Detection of Chromium Edge on Windows
  • Loading branch information
mssola authored Aug 25, 2020
2 parents 48f5012 + ea81f1e commit 7759c7a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix detection of Firefox on iPad.
- Fix detection of Linux ARM-based Android.
- Add detection of Chromium Edge on Windows.

## 0.5.2

Expand Down
8 changes: 8 additions & 0 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ var uastrings = []struct {
expected: "Mozilla:5.0 Platform:Windows OS:Windows Phone 10.0 Browser:Edge-12.10240 Engine:EdgeHTML Bot:false Mobile:true",
},

// Microsoft Chromium Edge
{
title: "EdgeDesktop",
ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36 Edg/83.0.478.37",
expected: "Mozilla:5.0 Platform:Windows OS:Windows 10 Browser:Edge-83.0.478.37 Engine:AppleWebKit-537.36 Bot:false Mobile:false",
expectedOS: &OSInfo{"Windows 10", "Windows", "10"},
},

// Gecko
{
title: "FirefoxMac",
Expand Down
14 changes: 14 additions & 0 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,26 @@ func (p *UserAgent) detectBrowser(sections []section) {
}
p.browser.Version = sections[sectionIndex].version
if engine.name == "AppleWebKit" {
for _, comment := range engine.comment {
if len(comment) > 5 &&
(strings.HasPrefix(comment, "Googlebot") || strings.HasPrefix(comment, "bingbot")) {
p.undecided = true
break
}
}
switch sections[slen-1].name {
case "Edge":
p.browser.Name = "Edge"
p.browser.Version = sections[slen-1].version
p.browser.Engine = "EdgeHTML"
p.browser.EngineVersion = ""
case "Edg":
if p.undecided != true {
p.browser.Name = "Edge"
p.browser.Version = sections[slen-1].version
p.browser.Engine = "AppleWebKit"
p.browser.EngineVersion = sections[slen-2].version
}
case "OPR":
p.browser.Name = "Opera"
p.browser.Version = sections[slen-1].version
Expand Down

0 comments on commit 7759c7a

Please sign in to comment.