diff --git a/CHANGELOG.md b/CHANGELOG.md index f3411cb..bba0728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/all_test.go b/all_test.go index 264af3c..1290834 100644 --- a/all_test.go +++ b/all_test.go @@ -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", diff --git a/browser.go b/browser.go index ee1040f..cd838a5 100644 --- a/browser.go +++ b/browser.go @@ -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