Skip to content

samsung support and tests #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/browserslist_useragent/query_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QueryNormalizer
op_mini: 'OperaMini',
op_mob: 'OperaMobile',
and_qq: 'QQAndroid',
samsung: 'SamsungInternet',
and_uc: 'UCAndroid'
}.freeze

Expand Down
1 change: 1 addition & 0 deletions lib/browserslist_useragent/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def call
family = 'Explorer' if agent.family == 'IE'
family = 'ExplorerMobile' if agent.family == 'IE Mobile'
family = 'QQAndroid' if agent.family == 'QQ Browser Mobile'
family = 'SamsungInternet' if agent.family == 'Samsung Internet'
family = 'UCAndroid' if agent.family == 'UC Browser'

{ family: family, version: version }
Expand Down
8 changes: 7 additions & 1 deletion spec/browserslist_useragent/match_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[
'firefox 59', 'firefox 58', 'chrome 64', 'chrome 65',
'ie 10', 'and_uc 11.8', 'android 4.4.3-4.4.4',
'ios_saf 11.3', 'ios_saf 11.0-11.2'
'ios_saf 11.3', 'ios_saf 11.0-11.2', 'samsung 11.1-11.2', 'samsung 12.0'
]
end

Expand All @@ -31,6 +31,12 @@
it { expect(matcher).to be_browser }
end

context 'when family is Samsung' do
let(:user_agent) { { family: 'SamsungInternet' } }

it { expect(matcher).to be_browser }
end

context 'when family is BlackBerry' do
let(:user_agent) { { family: 'BlackBerry' } }

Expand Down
6 changes: 6 additions & 0 deletions spec/browserslist_useragent/query_normalizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@

it { expect(subject).to include(family: 'Chrome') }
end

context 'when browser is samsung' do
let(:query) { 'samsung 11.1-11.2' }

it { expect(subject).to include(family: 'SamsungInternet') }
end
end

describe 'version' do
Expand Down
9 changes: 9 additions & 0 deletions spec/browserslist_useragent/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,14 @@ def resolve_user_agent(user_agent)
)
).to eq(family: 'Firefox', version: '44.0.0')
end

it 'resolves samsung browser properly' do
# samsung browser
expect(
resolve_user_agent(
'Mozilla/5.0 (Linux; Android 10; LYA-L09) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.36'
)
).to eq(family: 'SamsungInternet', version: '12.1.0')
end
end
end