ua-parser-js
ua-parser-js copied to clipboard
Catch "Safari" and "Safari Mobile" in a single check
Is your feature request related to a problem? Please describe.
Today is("Safari") is does not catch variants like Mobile Safari. That's one example I came across but now I'm wondering if I'm missing other cases.
Describe the solution you'd like
It would be nice to have a helper function similar to is() but doing string matching instead of equality (eg. match()). I imagine that'd also help for Windows and Windows Phone and some other cases.
Describe alternatives you've considered
Right now I'm doing is("Safari") || is("Mobile Safari") but that feels a little precarious.
Thanks
Hi! Thanks for the suggestion, as a general rule, I'll consider to add a feature if there are enough users who need it as well.
In the mean time we can also use includes():
browser.name.includes("Safari")
Cool thanks, that's what I ended up doing but it is case-sensitive, which is() is a nice trick for.
Thanks for considering, and thank for the work.
Somewhat related question: Is Safari detected as Mobile Safari when device.type is tablet (i.e. in iPad)?