ua-parser-js icon indicating copy to clipboard operation
ua-parser-js copied to clipboard

Catch "Safari" and "Safari Mobile" in a single check

Open maphe opened this issue 8 months ago • 3 comments

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

maphe avatar Oct 18 '23 17:10 maphe

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")

faisalman avatar Oct 19 '23 03:10 faisalman

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.

maphe avatar Oct 19 '23 14:10 maphe

Somewhat related question: Is Safari detected as Mobile Safari when device.type is tablet (i.e. in iPad)?

aradalvand avatar Dec 08 '23 04:12 aradalvand