Skip to content

Commit

Permalink
Merge pull request #17 from woothee/update-v1_11
Browse files Browse the repository at this point in the history
Update: v1.11.0
  • Loading branch information
tagomoris committed Sep 7, 2021
2 parents 5a19241 + d2279d5 commit efc2b4d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
language: go
go:
- 1.1
- 1.2
- 1.3
- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
- "1.8"
- "1.9"
- "1.10"
- "1.11"
- "1.12"
- "1.13"
- "1.14"
- tip
install:
- echo "Do Nothing, please"
Expand Down
5 changes: 5 additions & 0 deletions dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ var DefaultDataSet DataSet = DataSet{
Type: "",
Vendor: "Fenrir Inc.",
},
"GSA": &Result{
Name: "Google Search App",
Type: "",
Vendor: "Google",
},
"Webview": &Result{
Name: "Webview",
Type: "",
Expand Down
11 changes: 11 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var (
rxFirefoxOSPattern = regexp.MustCompile(`^Mozilla/[.0-9]+ \((?:Mobile|Tablet);(?:.*;)? rv:([.0-9]+)\) Gecko/[.0-9]+ Firefox/[.0-9]+$`)
rxFirefoxiOSPattern = regexp.MustCompile(`FxiOS/([.0-9]+)`)
rxFOMAVersionPattern = regexp.MustCompile(`\(([^;)]+);FOMA;`)
rxGsaPattern = regexp.MustCompile(`GSA/([.0-9]+)`)
rxHeadlineReaderPattern = regexp.MustCompile(`(?i)headline-reader`)
rxJigPattern = regexp.MustCompile(`jig browser[^;]+; ([^);]+)`)
rxKDDIPattern = regexp.MustCompile(`KDDI-([^- /;()"']+)`)
Expand Down Expand Up @@ -1192,6 +1193,16 @@ func (p *Parser) ChallengeSafariChrome(agent string, result *Result) error {
return nil
}

if match := rxGsaPattern.FindStringSubmatchIndex(agent); match != nil {
version := agent[match[2]:match[3]]
err := p.PopulateDataSet(result, "GSA")
if err != nil {
return err
}
result.Version = version
return nil
}

version := ValueUnknown
if match := rxSafariPattern.FindStringSubmatchIndex(agent); match != nil {
version = agent[match[2]:match[3]]
Expand Down
20 changes: 20 additions & 0 deletions smartphone_ios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,26 @@ func Test_smartphone_ios(t *testing.T) {
t.Errorf("Expected result.Version for '%s' to be '41.1.35.1', but got '%s'", `Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89 Safari/603.2.4 EdgiOS/41.1.35.1`, result.Version)
}
}
result, err = Parse(`Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1`)
if err != nil {
t.Errorf(`Failed to parse 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1': %s`, err)
} else {
if result.Category != "smartphone" {
t.Errorf("Expected result.Category for '%s' to be 'smartphone', but got '%s'", `Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1`, result.Category)
}
if result.Name != "Google Search App" {
t.Errorf("Expected result.Name for '%s' to be 'Google Search App', but got '%s'", `Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1`, result.Name)
}
if true && result.Os != "iPhone" {
t.Errorf("Expected result.Os for '%s' to be 'iPhone', but got '%s'", `Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1`, result.Os)
}
if true && result.OsVersion != "11.1.1" {
t.Errorf("Expected result.OsVersion for '%s' to be '11.1.1', but got '%s'", `Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1`, result.OsVersion)
}
if true && result.Version != "41.0.178428663" {
t.Errorf("Expected result.Version for '%s' to be '41.0.178428663', but got '%s'", `Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) GSA/41.0.178428663 Mobile/15B150 Safari/604.1`, result.Version)
}
}
result, err = Parse(`Girls/2.0 (livedoor Co.,Ltd.; Peachy 2.1; iPhone; RSS Version 2.0; +http://girls.livedoor.com/)`)
if err != nil {
t.Errorf(`Failed to parse 'Girls/2.0 (livedoor Co.,Ltd.; Peachy 2.1; iPhone; RSS Version 2.0; +http://girls.livedoor.com/)': %s`, err)
Expand Down

0 comments on commit efc2b4d

Please sign in to comment.