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

Commit 6eb76c6

Browse files
committed
Add Yandex browser
1 parent 8b39990 commit 6eb76c6

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

all_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,19 @@ var uastrings = []struct {
333333
expected: "Platform:Windows OS:Windows 7 Localization:en Browser:Opera-9.80 Engine:Presto-2.9.168 Bot:false Mobile:false",
334334
},
335335

336+
// Yandex Browser
337+
{
338+
title: "YandexBrowserLinux",
339+
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",
340+
expected: "Mozilla:5.0 Platform:X11 OS:Linux x86_64 Browser:YaBrowser-19.1.0.2494 Engine:AppleWebKit-537.36 Bot:false Mobile:false",
341+
expectedOS: &OSInfo{"Linux x86_64", "Linux", ""},
342+
},
343+
344+
{
345+
title: "YandexBrowserWindows",
346+
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",
347+
expected: "Mozilla:5.0 Platform:Windows OS:Windows 7 Browser:YaBrowser-17.3.1.840 Engine:AppleWebKit-537.36 Bot:false Mobile:false",
348+
},
336349
// Other
337350
{
338351
title: "Empty",

browser.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,19 @@ func (p *UserAgent) detectBrowser(sections []section) {
6969
p.browser.Name = "Opera"
7070
p.browser.Version = sections[slen-1].version
7171
default:
72-
if sections[sectionIndex].name == "Chrome" {
73-
p.browser.Name = "Chrome"
74-
} else if sections[sectionIndex].name == "Chromium" {
75-
p.browser.Name = "Chromium"
76-
} else if sections[sectionIndex].name == "CriOS" {
77-
p.browser.Name = "Chrome"
78-
} else {
79-
p.browser.Name = "Safari"
72+
switch sections[slen-3].name {
73+
case "YaBrowser":
74+
p.browser.Name = "YaBrowser"
75+
p.browser.Version = sections[slen-3].version
76+
default:
77+
switch sections[sectionIndex].name {
78+
case "Chrome", "CriOS":
79+
p.browser.Name = "Chrome"
80+
case "Chromium":
81+
p.browser.Name = "Chromium"
82+
default:
83+
p.browser.Name = "Safari"
84+
}
8085
}
8186
}
8287
} else if engine.name == "Gecko" {

0 commit comments

Comments
 (0)