This repository was archived by the owner on Feb 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 9
9
"strings"
10
10
)
11
11
12
+ var botFromSiteRegexp = regexp .MustCompile ("http://.+\\ .\\ w+" )
13
+
12
14
// Get the name of the bot from the website that may be in the given comment. If
13
15
// there is no website in the comment, then an empty string is returned.
14
16
func getFromSite (comment []string ) string {
@@ -23,8 +25,7 @@ func getFromSite(comment []string) string {
23
25
}
24
26
25
27
// Pick the site.
26
- re := regexp .MustCompile ("http://.+\\ .\\ w+" )
27
- results := re .FindStringSubmatch (comment [idx ])
28
+ results := botFromSiteRegexp .FindStringSubmatch (comment [idx ])
28
29
if len (results ) == 1 {
29
30
// If it's a simple comment, just return the name of the site.
30
31
if idx == 0 {
Original file line number Diff line number Diff line change 9
9
"strings"
10
10
)
11
11
12
+ var ie11Regexp = regexp .MustCompile ("^rv:(.+)$" )
13
+
12
14
// A struct containing all the information that we might be
13
15
// interested from the browser.
14
16
type Browser struct {
@@ -75,9 +77,8 @@ func (p *UserAgent) detectBrowser(sections []section) {
75
77
// This is the new user agent from Internet Explorer 11.
76
78
p .browser .Engine = "Trident"
77
79
p .browser .Name = "Internet Explorer"
78
- reg , _ := regexp .Compile ("^rv:(.+)$" )
79
80
for _ , c := range sections [0 ].comment {
80
- version := reg .FindStringSubmatch (c )
81
+ version := ie11Regexp .FindStringSubmatch (c )
81
82
if len (version ) > 0 {
82
83
p .browser .Version = version [1 ]
83
84
return
You can’t perform that action at this time.
0 commit comments