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

Commit

Permalink
Add Yandex browser
Browse files Browse the repository at this point in the history
  • Loading branch information
kshvakov committed Feb 21, 2019
1 parent 8b39990 commit 6eb76c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
13 changes: 13 additions & 0 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,19 @@ var uastrings = []struct {
expected: "Platform:Windows OS:Windows 7 Localization:en Browser:Opera-9.80 Engine:Presto-2.9.168 Bot:false Mobile:false",
},

// Yandex Browser
{
title: "YandexBrowserLinux",
ua: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 YaBrowser/19.1.0.2494 (beta) Yowser/2.5 Safari/537.36",
expected: "Mozilla:5.0 Platform:X11 OS:Linux x86_64 Browser:YaBrowser-19.1.0.2494 Engine:AppleWebKit-537.36 Bot:false Mobile:false",
expectedOS: &OSInfo{"Linux x86_64", "Linux", ""},
},

{
title: "YandexBrowserWindows",
ua: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 YaBrowser/17.3.1.840 Yowser/2.5 Safari/537.36",
expected: "Mozilla:5.0 Platform:Windows OS:Windows 7 Browser:YaBrowser-17.3.1.840 Engine:AppleWebKit-537.36 Bot:false Mobile:false",
},
// Other
{
title: "Empty",
Expand Down
21 changes: 13 additions & 8 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,19 @@ func (p *UserAgent) detectBrowser(sections []section) {
p.browser.Name = "Opera"
p.browser.Version = sections[slen-1].version
default:
if sections[sectionIndex].name == "Chrome" {
p.browser.Name = "Chrome"
} else if sections[sectionIndex].name == "Chromium" {
p.browser.Name = "Chromium"
} else if sections[sectionIndex].name == "CriOS" {
p.browser.Name = "Chrome"
} else {
p.browser.Name = "Safari"
switch sections[slen-3].name {
case "YaBrowser":
p.browser.Name = "YaBrowser"
p.browser.Version = sections[slen-3].version
default:
switch sections[sectionIndex].name {
case "Chrome", "CriOS":
p.browser.Name = "Chrome"
case "Chromium":
p.browser.Name = "Chromium"
default:
p.browser.Name = "Safari"
}
}
}
} else if engine.name == "Gecko" {
Expand Down

0 comments on commit 6eb76c6

Please sign in to comment.