-
Notifications
You must be signed in to change notification settings - Fork 1
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
Remove @financial-times/polyfill-useragent-normaliser
dependency
#92
base: main
Are you sure you want to change the base?
Remove @financial-times/polyfill-useragent-normaliser
dependency
#92
Conversation
@@ -1,11 +1,35 @@ | |||
const semver = require('semver'); | |||
const uap = require('ua-parser-js'); | |||
|
|||
const SHORT_UA_REGEX = /^(android|bb|chrome|edge|edge_mob|firefox|firefox_mob|ie|ie_mob|safari|ios_saf|opera|op_mob|op_mini|samsung_mob|other)\/((?:\d+\.)*\d+)$/i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ios_saf/10.0
format is not parseable by ua-parser-js
. But a simple regex is sufficient to handle those cases.
|
||
Support data only exists for the most common browsers (e.g. Chrome, Firefox, Safari, ...). To map any user agent to a list of needed polyfills you need to normalize the user agent to one of the known browser families and their corresponding version. | ||
|
||
Since the `@financial-times/polyfill-useragent-normaliser` package was deprecated you might need to provide your own solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we could provide a solution here. I think it will be difficult for another organization to provide this library, given that the list of normalized families and versions is so tightly coupled to polyfill-library
.
What if we publish our own normalizer? At first, it could just be a wrapper around @financial-times/polyfill-useragent-normaliser
(thus avoiding users of polyfill-library
depending directly on it), and then we can decide whether we want to fork it or transition to another normalizer.
Resolves: #86