faisalman / ua-parser-js

"Unmask Your Traffic" - UAParser.js: The Essential Web Development Tool for User-Agent Detection
https://uaparser.dev/
GNU Affero General Public License v3.0
9.28k stars 1.19k forks source link

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

Open maphe opened 1 year ago

maphe commented 1 year ago

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

faisalman commented 1 year ago

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")
maphe commented 1 year ago

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.

aradalvand commented 11 months ago

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