File tree Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 33## Unreleased
44
55- Handle Snapchat user agents that have a space or an empty string instead of a slash before the version.
6+ - Fix iOS 10+ version detection.
67- Add fallback versions for instagram and snapchat to avoid NoMethodErrors on unexpected user agents.
78
89## 2.7.0
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module Browser
44 class Platform
55 class IOS < Base
66 MATCHER = /(iPhone|iPad|iPod)/ . freeze
7- VERSION_MATCHER = /OS ((?<major>\d )_(?<minor>\d )_?(?<patch>\d )?)/ . freeze
7+ VERSION_MATCHER = /OS ((?<major>\d + )_(?<minor>\d + )_?(?<patch>\d + )?)/ . freeze # rubocop:disable Metrics/LineLength
88
99 def version
1010 matches = VERSION_MATCHER . match ( ua )
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ IOS8: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4
6666IOS8_1_2 : ' Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4'
6767IOS8_3 : ' Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4'
6868IOS9 : " Mozilla/5.0 (iPad; CPU OS 9_0 like Mac OS X) AppleWebKit/601.1.17 (KHTML, like Gecko) Version/8.0 Mobile/13A175 Safari/600.1.4"
69+ IOS12 : " Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1"
6970IOS_WEBVIEW : Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H141
7071IPAD : " Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10"
7172IPHONE : " Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/1A542a Safari/419.3"
Original file line number Diff line number Diff line change @@ -105,6 +105,13 @@ class IosTest < Minitest::Test
105105 refute browser . platform . mac?
106106 end
107107
108+ test "detects ios12" do
109+ browser = Browser . new ( Browser [ "IOS12" ] )
110+ assert browser . platform . ios?
111+ assert browser . platform . ios? ( 12 )
112+ refute browser . platform . mac?
113+ end
114+
108115 test "don't detect as two different versions" do
109116 browser = Browser . new ( Browser [ "IOS8" ] )
110117 assert browser . platform . ios? ( 8 )
You can’t perform that action at this time.
0 commit comments