Files
docuseal/lib/detect_browser_device.rb
T

38 lines
723 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module DetectBrowserDevice
module_function
2025-10-22 15:53:41 +03:00
MOBILE_USER_AGENT_REGEXP = /
iPhone |
iPod |
Android.*Mobile|
Opera\ Mini |
Opera\ Mobi |
webOS |
IEMobile |
Windows\ Phone |
BlackBerry |
BB10 |
Mobile
/ix
TABLET_USER_AGENT_REGEXP = /
iPad |
Android(?!.*Mobile)|
Tablet |
Kindle |
PlayBook |
Silk
/ix
def call(user_agent)
2025-11-12 16:44:58 +02:00
return if user_agent.blank?
2025-11-12 16:44:58 +02:00
return 'mobile' if MOBILE_USER_AGENT_REGEXP.match?(user_agent)
return 'tablet' if TABLET_USER_AGENT_REGEXP.match?(user_agent)
2025-11-12 16:44:58 +02:00
'desktop'
end
end