diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-09-23 10:17:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-23 10:17:51 -0400 |
commit | 2ca0e8f9a0f9863555a26e984cde15efff9ef8f8 (patch) | |
tree | daae1ee67b14a3d0a84424f2a304885d9e75ce2b /vendor/github.com/mssola/user_agent/bot.go | |
parent | 6d62d65b2dc85855aabea036cbd44f6059e19d13 (diff) | |
download | chat-2ca0e8f9a0f9863555a26e984cde15efff9ef8f8.tar.gz chat-2ca0e8f9a0f9863555a26e984cde15efff9ef8f8.tar.bz2 chat-2ca0e8f9a0f9863555a26e984cde15efff9ef8f8.zip |
Updating golang dependancies (#4075)
Diffstat (limited to 'vendor/github.com/mssola/user_agent/bot.go')
-rw-r--r-- | vendor/github.com/mssola/user_agent/bot.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/vendor/github.com/mssola/user_agent/bot.go b/vendor/github.com/mssola/user_agent/bot.go index 2b118d661..efcab9253 100644 --- a/vendor/github.com/mssola/user_agent/bot.go +++ b/vendor/github.com/mssola/user_agent/bot.go @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2016 Miquel Sabaté Solà <mikisabate@gmail.com> +// Copyright (C) 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 botFromSiteRegexp = regexp.MustCompile("http://.+\\.\\w+") - // Get the name of the bot from the website that may be in the given comment. If // there is no website in the comment, then an empty string is returned. func getFromSite(comment []string) string { @@ -25,7 +23,8 @@ func getFromSite(comment []string) string { } // Pick the site. - results := botFromSiteRegexp.FindStringSubmatch(comment[idx]) + re := regexp.MustCompile("http://.+\\.\\w+") + results := re.FindStringSubmatch(comment[idx]) if len(results) == 1 { // If it's a simple comment, just return the name of the site. if idx == 0 { @@ -75,8 +74,6 @@ func (p *UserAgent) fixOther(sections []section) { } } -var botRegex = regexp.MustCompile("(?i)(bot|crawler|sp(i|y)der|search|worm|fetch|nutch)") - // Check if we're dealing with a bot or with some weird browser. If that is the // case, the receiver will be modified accordingly. func (p *UserAgent) checkBot(sections []section) { @@ -85,8 +82,9 @@ func (p *UserAgent) checkBot(sections []section) { if len(sections) == 1 && sections[0].name != "Mozilla" { p.mozilla = "" - // Check whether the name has some suspicious "bot" or "crawler" in his name. - if botRegex.Match([]byte(sections[0].name)) { + // Check whether the name has some suspicious "bot" in his name. + reg, _ := regexp.Compile("(?i)bot") + if reg.Match([]byte(sections[0].name)) { p.setSimple(sections[0].name, "", true) return } |