From 2ca0e8f9a0f9863555a26e984cde15efff9ef8f8 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Fri, 23 Sep 2016 10:17:51 -0400 Subject: Updating golang dependancies (#4075) --- vendor/github.com/mssola/user_agent/bot.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'vendor/github.com/mssola/user_agent/bot.go') 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à +// Copyright (C) 2014 Miquel Sabaté Solà // 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 } -- cgit v1.2.3-1-g7c22