diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-06-21 19:06:17 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-06-21 19:06:17 -0700 |
commit | 42f28ab8e374137fe3f5d25424489d879d4724f8 (patch) | |
tree | 20353f2446b506d32e6d353b72a57bf48f070389 /vendor/github.com/mssola/user_agent/browser.go | |
parent | 6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff) | |
download | chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2 chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip |
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/github.com/mssola/user_agent/browser.go')
-rw-r--r-- | vendor/github.com/mssola/user_agent/browser.go | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/vendor/github.com/mssola/user_agent/browser.go b/vendor/github.com/mssola/user_agent/browser.go index fbed92176..74fb931ef 100644 --- a/vendor/github.com/mssola/user_agent/browser.go +++ b/vendor/github.com/mssola/user_agent/browser.go @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2017 Miquel Sabaté Solà <mikisabate@gmail.com> +// Copyright (C) 2012-2014 Miquel Sabaté Solà <mikisabate@gmail.com> // This file is licensed under the MIT license. // See the LICENSE file. @@ -9,8 +9,6 @@ import ( "strings" ) -var ie11Regexp = regexp.MustCompile("^rv:(.+)$") - // A struct containing all the information that we might be // interested from the browser. type Browser struct { @@ -36,46 +34,27 @@ func (p *UserAgent) detectBrowser(sections []section) { slen := len(sections) if sections[0].name == "Opera" { + p.mozilla = "" p.browser.Name = "Opera" p.browser.Version = sections[0].version p.browser.Engine = "Presto" if slen > 1 { p.browser.EngineVersion = sections[1].version } - } else if sections[0].name == "Dalvik" { - // When Dalvik VM is in use, there is no browser info attached to ua. - // Although browser is still a Mozilla/5.0 compatible. - p.mozilla = "5.0" } else if slen > 1 { engine := sections[1] p.browser.Engine = engine.name p.browser.EngineVersion = engine.version if slen > 2 { - sectionIndex := 2 - // The version after the engine comment is empty on e.g. Ubuntu - // platforms so if this is the case, let's use the next in line. - if sections[2].version == "" && slen > 3 { - sectionIndex = 3 - } - p.browser.Version = sections[sectionIndex].version + p.browser.Version = sections[2].version if engine.name == "AppleWebKit" { - 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 "OPR": + if sections[slen-1].name == "OPR" { 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 { - p.browser.Name = "Safari" - } + } else if sections[2].name == "Chrome" { + p.browser.Name = "Chrome" + } else { + p.browser.Name = "Safari" } } else if engine.name == "Gecko" { name := sections[2].name @@ -88,8 +67,9 @@ func (p *UserAgent) detectBrowser(sections []section) { // This is the new user agent from Internet Explorer 11. p.browser.Engine = "Trident" p.browser.Name = "Internet Explorer" + reg, _ := regexp.Compile("^rv:(.+)$") for _, c := range sections[0].comment { - version := ie11Regexp.FindStringSubmatch(c) + version := reg.FindStringSubmatch(c) if len(version) > 0 { p.browser.Version = version[1] return |