browserslist / browserslist-useragent-ruby Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The readme states to include the browsers.json generating code in the webpack config, however in a Rails/Webpacker environment there is no straightforward webpack config js file. Is this gem compatible with Webpacker?
We're using this gem and on the following Chrome 53 UA string:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/535.14.61 (KHTML, like Gecko) Chrome/53.5.0289.5916 Safari/534.43
We received the following error:
ArgumentError
53.5.0289 is not a valid SemVer Version (http://semver.org)
It seems that this is definitely an allowable version number. Could I suggest using Gem::Version
to parse the version number instead? I also think this gem should define its own exception class if there's a true problem with parsing as well instead of just throwing an ArgumentError
, which is very broad and could potentially mask lots of other issues.
The for inside lib/
must have the same name as gem. Otherwise you will have name conflict with some browserslist
in the future.
Feel free to move the repo to browserslist. But first you need to fix docs and rename repo to browserslist-useragent-ruby
.
gem install
step. Bundler is everywhere.Great idea to create a gem. Feel free to ask me about open source promotion.
I'm submitting a ...
What is the current behavior?
matcher.browser?
returns false
even though it is in my .browserlistrc
What is the expected behavior?
matcher.browser?
should return true
What is the motivation / use case for changing the behavior?
The current behaviour seems incorrect
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
Seems to fail because of a whitespace:
30: def browser?
31: target_browser = user_agent[:family].downcase
=> 32: queries.key?(target_browser)
33: end
[1] pry(#<BrowserslistUseragent::Match>)> target_browser
=> "opera mobile"
[2] pry(#<BrowserslistUseragent::Match>)> queries
=> {"chrome"=>["81", "83", "81", "80"],
"firefox"=>["68", "78", "77", "76", "68"],
"qqandroid"=>["10.4"],
"ucandroid"=>["12.12"],
"android"=>["81"],
"baidu"=>["7.12"],
"edge"=>["83", "81", "18"],
"ios"=>["13.4-13.5", "13.3", "12.2-12.4"],
"kaios"=>["2.5"],
"operamini"=>["all"],
"operamobile"=>["46"],
"opera"=>["69", "68"],
"safari"=>["13.1", "13"],
"samsung"=>["12.0", "11.1-11.2"]}
A potential solution could be to adjust the resolver.rb to handle opera mobile.
First off, thanks for this package. It's been extremely helpful in our efforts to standardize supported browsers within our team.
I'm having an issue with a specific browser. Given the following code in Rails:
matcher = BrowserslistUseragent::Match.new(
['safari 11.1'],
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15'
)
logger.debug "#{matcher.browser?}"
logger.debug "#{matcher.version?(allow_higher: true)}"
Output is
false
false
Same thing with (just realized the browsers.json is likely created to avoid matching against this syntax)last 2 Safari versions
query (or any last X Safari versions query for that matter).
I tried the same user agent in the node package (browserslist-useragent) and it returned true.
This is potentially a bug, or some imprecision/ambiguity in one of the code comments.
There are two cases related to resolving the iOS version within resolver.rb
browserslist-useragent-ruby/lib/browserslist_useragent/resolver.rb
Lines 20 to 34 in f17624b
Case B explains;
Case B: The browser on iOS didn't report as safari, so we use the iOS version as a proxy to the browser version. This is based on the assumption that the underlying Safari Engine used will be atleast equal to the iOS version it's running on.
However the condition used for this is simply
if agent.os.family == 'iOS'
As such, whether the browser identifies as Safari or not, the version number is set to the os version; making Case A redundant,
The comment would seem to suggest that there should be logic that is specifically checking for the absence of Safari;
if !agent.family.include?('Safari') && agent.os.family == 'iOS'
As background, this stems from the following real-world example;
ua = 'Mozilla/5.0 (iPad; CPU OS 12_5_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1'
matcher = BrowserslistUseragent::Match.new(['ios_saf 12.2-12.5'], ua)
matcher.browser? && matcher.version?(allow_higher: true)
=> true
Where although it is Safari and iOS, it is replacing the browser version 12.1.2
with the os version 12.5.6
and returning a match.
This potentially doesn't match the expectation based on the Case B comment.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.