browser_sniffer 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54581761d65c647fadd686bbf33ef750e2a7baef8d8c17d5ad972e0247f4d8d8
4
- data.tar.gz: 00576a56f63e866bd9a887f231fe40159be142a978c855ce58e7f315cd25b232
3
+ metadata.gz: 7a40b8a9409737267257c6f483d852934412d648c1ed126c8e94cb673fab7b32
4
+ data.tar.gz: 7c9cb6ef28afe9e07dee3d04a5af69e2629d885a3b4f83003b4890cdc0a25228
5
5
  SHA512:
6
- metadata.gz: def03033a32783bac770738b6195a9a2f8ce4837ca467f89a13babce04e3035e092a476ae31247a401d438347c2fc584a4d1fe044d2252a49ed6f03bc4c6359a
7
- data.tar.gz: 62f2d75552256242418a85e31d90e3b17457949bd14b32eb375afaf41faf88939d60ca4b3df4ef33e81bb4fd6176a8eb848ffb3305f2e3b134f420382cdf028c
6
+ metadata.gz: b1db89af88e1acbcae5bf21033f03a27ebd8653fca7154d6831270855e61addf1592ab694582e7cbc9ffaff7809b57003e98de0501257bcb8a4be99e74d1ea9e
7
+ data.tar.gz: d53de5538c4e6ecca8461e53590459918fc9a61f8a7d34227bd441bd53e47e804cf79cccb0102be76deb4e64cf4e0e52a7c4a0a2bf065026d32d7ab09eec211e
@@ -46,10 +46,10 @@ class BrowserSniffer
46
46
  :browser => [
47
47
  [
48
48
  # Shopify Mobile for iPhone or iPad
49
- %r{^Shopify/\d+\s\((iPhone|iPad)\;\siOS\s[\d\.]+}i
49
+ %r{.*Shopify/\d+\s\((iPhone|iPad)\;\siOS\s[\d\.]+}i
50
50
  ], [[:name, 'Shopify Mobile']], [
51
51
  # Shopify Mobile for Android
52
- %r{^Dalvik/[a-z0-9\.]+.*Shopify\s[\d+\.\/]+}i
52
+ %r{.*Dalvik/[a-z0-9\.]+.*Shopify\s[\d+\.\/]+}i
53
53
  ], [[:name, 'Shopify Mobile']], [
54
54
  # Shopify POS for iOS
55
55
  %r{.*(Shopify\sPOS)\/([\d\.]+)\s\((iPhone|iPad|iPod\stouch)\;}i,
@@ -67,16 +67,16 @@ class BrowserSniffer
67
67
  %r{^(okhttp)\/([\d\.]+)}i
68
68
  ], [:name, :version], [
69
69
  # Shopify Mobile for iPhone or iPad
70
- %r{^(Shopify Mobile)\/(?:iPhone\sOS|iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
70
+ %r{.*(Shopify Mobile)\/(?:iPhone\sOS|iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
71
71
  ], [[:name, 'Shopify Mobile'], :version], [
72
72
  # Shopify Mobile for Android
73
- %r{^(Shopify Mobile)\/Android\/([\d\.]+(?: \(debug(?:|-push)\))?) \(Build (\d+) with API (\d+)}i
73
+ %r{.*(Shopify Mobile)\/Android\/([\d\.]+(?: \(debug(?:|-push)\))?) \(Build (\d+) with API (\d+)}i
74
74
  ], [[:name, 'Shopify Mobile'], :version, :build, :sdk_version], [
75
75
  # ShopifyFoundation shared library
76
76
  /^(ShopifyFoundation)/i,
77
77
  ], [:name], [
78
78
  # Shopify Ping iOS
79
- %r{^(Shopify Ping)\/(?:iPhone\sOS|iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
79
+ %r{.*(Shopify Ping)\/(?:iPhone\sOS|iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
80
80
  ], [[:name, 'Shopify Ping'], :version], [
81
81
  # Presto based
82
82
  /(opera\smini)\/((\d+)?[\w\.-]+)/i, # Opera Mini
@@ -151,19 +151,19 @@ class BrowserSniffer
151
151
  :device => [
152
152
  [
153
153
  # Shopify Mobile for iPhone
154
- %r{^Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
154
+ %r{.*Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
155
155
  ], [[:type, :handheld], :model], [
156
156
  # Shopify Mobile for iPad
157
- %r{^Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPad)([\d,]+)}i
157
+ %r{.*Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPad)([\d,]+)}i
158
158
  ], [[:type, :tablet], :model], [
159
159
  # Shopify Mobile for iPod touch
160
- %r{^Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPod)([\d,]+)}i
160
+ %r{.*Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPod)([\d,]+)}i
161
161
  ], [[:type, :handheld], :model], [
162
162
  # Shopify Ping for iPhone
163
- %r{^Shopify Ping/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
163
+ %r{.*Shopify Ping/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
164
164
  ], [[:type, :handheld], :model], [
165
165
  # Shopify Mobile for Android
166
- %r{^Shopify Mobile\/(Android)\/[\d\.]+(?: \(debug(?:|-push)\))? \(Build \d+ with API \d+ on (.*?) (.*)\)}i
166
+ %r{.*Shopify Mobile\/(Android)\/[\d\.]+(?: \(debug(?:|-push)\))? \(Build \d+ with API \d+ on (.*?) ([^\)]*)\)}i
167
167
  ], [[:type, :handheld], :vendor, :model], [
168
168
  # Shopify POS for iPhone
169
169
  %r{.*Shopify POS\/[\d\.]+ \((iPhone)\;.*Scale/([\d\.]+)}i,
@@ -262,7 +262,7 @@ class BrowserSniffer
262
262
  :os => [
263
263
  [
264
264
  # Shopify Mobile for iOS
265
- %r{^Shopify/\d+\s\((?:iPhone|iPad)\;\s(iOS)\s([\d\.]+)}i
265
+ %r{.*Shopify/\d+\s\((?:iPhone|iPad)\;\s(iOS)\s([\d\.]+)}i
266
266
  ], [[:type, :ios], :version, [:name, 'iOS']], [
267
267
  # Shopify POS for iOS
268
268
  %r{.*Shopify\sPOS/[\d\.]+\s\((?:iPhone|iPad|iPod\stouch)\;\s(iOS)\s([\d\.]+)}i,
@@ -274,16 +274,16 @@ class BrowserSniffer
274
274
  /.*Shopify\sPOS\s.*(Android)\s([\d\.]+)\;\s.*\s[\d+\.]+\s/i,
275
275
  ], [[:type, :android], :version, [:name, 'Android']], [
276
276
  # Shopify Mobile for iOS
277
- %r{^Shopify Mobile\/(iPhone\sOS|iOS)\/[\d\.]+ \(.*\/OperatingSystemVersion\((.*)\)}i
277
+ %r{.*Shopify Mobile\/(iPhone\sOS|iOS)\/[\d\.]+ \(.*\/OperatingSystemVersion\((.*)\)}i
278
278
  ], [[:type, :ios], [:version, lambda { |str| str && str.scan(/\d+/).join(".") }], [:name, 'iOS']], [
279
279
  # Shopify Mobile for iPhone or iPad
280
- %r{^(Shopify Mobile)\/(?:iPhone\sOS|iOS)[\/\d\.]* \((iPhone|iPad|iPod).*\/([\d\.]+)}i
280
+ %r{.*(Shopify Mobile)\/(?:iPhone\sOS|iOS)[\/\d\.]* \((iPhone|iPad|iPod).*\/([\d\.]+)\)}i
281
281
  ], [[:type, :ios], [:name, 'iOS'], :version], [
282
282
  # Shopify Ping for iOS
283
- %r{^Shopify Ping\/(iOS)\/[\d\.]+ \(.*\/([\d\.]+)\)}i
283
+ %r{.*Shopify Ping\/(iOS)\/[\d\.]+ \(.*\/([\d\.]+)\)}i
284
284
  ], [[:type, :ios], :version, [:name, 'iOS']], [
285
285
  # Shopify Mobile for Android
286
- %r{^Shopify Mobile\/(Android)\/[\d\.]+ }i
286
+ %r{.*Shopify Mobile\/(Android)\/[\d\.]+ }i
287
287
  ], [:name, [:type, :android]], [
288
288
  # Windows based
289
289
  /(windows)\snt\s6\.2;\s(arm)/i, # Windows RT
@@ -1,3 +1,3 @@
1
1
  class BrowserSniffer
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -21,6 +21,27 @@ describe "Shopify agents" do
21
21
  version: '10.3.2',
22
22
  name: 'iOS',
23
23
  }), sniffer.os_info
24
+
25
+ user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "\
26
+ "AppleWebKit/ 604.1.21 (KHTML, like Gecko) Version/ 12.0 Mobile/17A6278a Safari/602.1.26 "\
27
+ "MobileMiddlewareSupported Shopify Mobile/iOS/8.12.0 (iPad4,7/com.shopify.ShopifyInternal/12.0.0)"
28
+ sniffer = BrowserSniffer.new(user_agent)
29
+
30
+ assert_equal ({
31
+ name: 'Shopify Mobile',
32
+ version: '8.12.0',
33
+ }), sniffer.browser_info
34
+
35
+ assert_equal ({
36
+ type: :tablet,
37
+ model: '4,7',
38
+ }), sniffer.device_info
39
+
40
+ assert_equal ({
41
+ type: :ios,
42
+ version: '12.0.0',
43
+ name: 'iOS',
44
+ }), sniffer.os_info
24
45
  end
25
46
 
26
47
  it "Shopify Mobile on iPod touch can be sniffed" do
@@ -43,6 +64,27 @@ describe "Shopify agents" do
43
64
  version: '9.3.5',
44
65
  name: 'iOS',
45
66
  }), sniffer.os_info
67
+
68
+ user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "\
69
+ "AppleWebKit/ 604.1.21 (KHTML, like Gecko) Version/ 12.0 Mobile/17A6278a Safari/602.1.26 "\
70
+ "MobileMiddlewareSupported Shopify Mobile/iOS/8.12.0 (iPod5,1/com.shopify.ShopifyInternal/12.0.0)"
71
+ sniffer = BrowserSniffer.new(user_agent)
72
+
73
+ assert_equal ({
74
+ name: 'Shopify Mobile',
75
+ version: '8.12.0',
76
+ }), sniffer.browser_info
77
+
78
+ assert_equal ({
79
+ type: :handheld,
80
+ model: '5,1',
81
+ }), sniffer.device_info
82
+
83
+ assert_equal ({
84
+ type: :ios,
85
+ version: '12.0.0',
86
+ name: 'iOS',
87
+ }), sniffer.os_info
46
88
  end
47
89
 
48
90
  it "Shopify Mobile on iPhone is detected as handheld" do
@@ -51,6 +93,13 @@ describe "Shopify agents" do
51
93
  sniffer = BrowserSniffer.new(user_agent)
52
94
  assert_equal :handheld, sniffer.form_factor
53
95
  assert sniffer.handheld?
96
+
97
+ user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "\
98
+ "AppleWebKit/ 604.1.21 (KHTML, like Gecko) Version/ 12.0 Mobile/17A6278a Safari/602.1.26 "\
99
+ "MobileMiddlewareSupported Shopify Mobile/iOS/8.12.0 (iPhone9,3/com.shopify.ShopifyInternal/12.0.0)"
100
+ sniffer = BrowserSniffer.new(user_agent)
101
+ assert_equal :handheld, sniffer.form_factor
102
+ assert sniffer.handheld?
54
103
  end
55
104
 
56
105
  it "Shopify Mobile on iPad is detected as tablet" do
@@ -59,6 +108,13 @@ describe "Shopify agents" do
59
108
  sniffer = BrowserSniffer.new(user_agent)
60
109
  assert_equal :tablet, sniffer.form_factor
61
110
  assert sniffer.tablet?
111
+
112
+ user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "\
113
+ "AppleWebKit/ 604.1.21 (KHTML, like Gecko) Version/ 12.0 Mobile/17A6278a Safari/602.1.26 "\
114
+ "MobileMiddlewareSupported Shopify Mobile/iOS/8.12.0 (iPad9,3/com.shopify.ShopifyInternal/12.0.0)"
115
+ sniffer = BrowserSniffer.new(user_agent)
116
+ assert_equal :tablet, sniffer.form_factor
117
+ assert sniffer.tablet?
62
118
  end
63
119
 
64
120
  it "Shopify Mobile on iPhone OS is detected as iOS" do
@@ -67,6 +123,13 @@ describe "Shopify agents" do
67
123
  sniffer = BrowserSniffer.new(user_agent)
68
124
  assert_equal :ios, sniffer.os
69
125
  assert sniffer.ios?
126
+
127
+ user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "\
128
+ "AppleWebKit/ 604.1.21 (KHTML, like Gecko) Version/ 12.0 Mobile/17A6278a Safari/602.1.26 "\
129
+ "MobileMiddlewareSupported Shopify Mobile/iOS/8.12.0 (iPad9,3/com.shopify.ShopifyInternal/12.0.0)"
130
+ sniffer = BrowserSniffer.new(user_agent)
131
+ assert_equal :ios, sniffer.os
132
+ assert sniffer.ios?
70
133
  end
71
134
 
72
135
  it "Shopify Mobile version is delected on iPhone OS" do
@@ -75,6 +138,14 @@ describe "Shopify agents" do
75
138
  assert_equal "6.6.2", sniffer.browser_version
76
139
  assert_equal "11.0.2", sniffer.os_version
77
140
  assert sniffer.ios?
141
+
142
+ user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) "\
143
+ "AppleWebKit/ 604.1.21 (KHTML, like Gecko) Version/ 12.0 Mobile/17A6278a Safari/602.1.26 "\
144
+ "MobileMiddlewareSupported Shopify Mobile/iOS/6.6.2 (iPad9,3/com.shopify.ShopifyInternal/11.0.2)"
145
+ sniffer = BrowserSniffer.new(user_agent)
146
+ assert_equal "6.6.2", sniffer.browser_version
147
+ assert_equal "11.0.2", sniffer.os_version
148
+ assert sniffer.ios?
78
149
  end
79
150
 
80
151
  it "Shopify Mobile on Android can be sniffed" do
@@ -98,6 +169,29 @@ describe "Shopify agents" do
98
169
  name: 'Android',
99
170
  type: :android,
100
171
  }), sniffer.os_info
172
+
173
+ user_agent = "Shopify Mobile/Android/8.12.0 (Build 12005 with API 28 on Google Android SDK built for x86) "\
174
+ "MobileMiddlewareSupported Mozilla/5.0 (Linux; Android 9; Android SDK built for x86 Build/PSR1.180720.075; wv) "\
175
+ "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36"
176
+ sniffer = BrowserSniffer.new(user_agent)
177
+
178
+ assert_equal ({
179
+ name: 'Shopify Mobile',
180
+ version: '8.12.0',
181
+ build: '12005',
182
+ sdk_version: '28',
183
+ }), sniffer.browser_info
184
+
185
+ assert_equal ({
186
+ type: :handheld,
187
+ vendor: 'Google',
188
+ model: 'Android SDK built for x86',
189
+ }), sniffer.device_info
190
+
191
+ assert_equal ({
192
+ name: 'Android',
193
+ type: :android,
194
+ }), sniffer.os_info
101
195
  end
102
196
 
103
197
  it "Shopify Mobile on Android simulator can be sniffed" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler