Skip to content
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

add Opera Mobile as agent family #16

Open
wants to merge 2 commits 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/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def call
family = 'Firefox' if agent.family == 'Firefox Mobile'
family = 'Explorer' if agent.family == 'IE'
family = 'ExplorerMobile' if agent.family == 'IE Mobile'
family = 'OperaMobile' if agent.family == 'Opera Mobile'
family = 'QQAndroid' if agent.family == 'QQ Browser Mobile'
family = 'UCAndroid' if agent.family == 'UC Browser'

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', 'op_mob 46'
]
end

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

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

it { expect(matcher).to be_browser }
end

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

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

it 'resolves opera mobile properly' do
expect(
resolve_user_agent(
'Mozilla/5.0 (Linux; Android 10; LYA-L09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36 OPR/59.1.2926.54067'
)
).to eq(family: 'OperaMobile', version: '59.1.2926')
end
end
end