class RailsSameSiteCookie::UserAgentChecker
Constants
- PARSER
Attributes
user_agent[R]
Public Class Methods
new(user_agent=nil)
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 14 def initialize(user_agent=nil) @user_agent_str = user_agent @user_agent = PARSER.parse(user_agent) if user_agent end
Public Instance Methods
chrome?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 24 def chrome? is_chromium_based? end
send_same_site_none?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 19 def send_same_site_none? return true if user_agent.nil? or @user_agent_str == '' return !missing_same_site_none_support? end
user_agent=(user_agent)
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 9 def user_agent=(user_agent) @user_agent_str = user_agent @user_agent = user_agent ? PARSER.parse(user_agent) : nil end
Private Instance Methods
has_webkit_ss_bug?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 33 def has_webkit_ss_bug? is_ios_version?('12') or (is_mac_osx_version?('10','14') and is_safari?) end
is_buggy_chrome?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 53 def is_buggy_chrome? is_chromium_based? and is_chromium_version_between?((51...67)) end
is_buggy_uc?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 57 def is_buggy_uc? is_uc_browser? and not is_uc_version_at_least?(12,13,2) end
is_chromium_based?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 61 def is_chromium_based? /Chrom(e|ium)/.match(@user_agent_str) end
is_chromium_version_between?(range)
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 65 def is_chromium_version_between?(range) match = /Chrom[^\/]+\/(\d+)[\.\d]*/.match(@user_agent_str) return false unless match version = match[1].to_i return range.include?(version) end
is_ios_version?(major)
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 41 def is_ios_version?(major) user_agent.os&.family == 'iOS' and user_agent.os&.version&.major == major end
is_mac_osx_version?(major,minor)
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 45 def is_mac_osx_version?(major,minor) user_agent.os&.family == 'Mac OS X' and user_agent.os&.version&.major == major and user_agent.os&.version&.minor == minor end
is_safari?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 49 def is_safari? /Safari/.match(user_agent.family) end
is_uc_browser?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 72 def is_uc_browser? user_agent.family == 'UC Browser' end
is_uc_version_at_least?(major,minor,build)
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 76 def is_uc_version_at_least?(major,minor,build) if user_agent.version&.major&.to_i == major if user_agent.version&.minor&.to_i == minor return user_agent.version&.patch&.to_i >= build else return user_agent.version&.minor&.to_i > minor end else return user_agent.version&.major&.to_i > major end end
missing_same_site_none_support?()
click to toggle source
# File lib/rails_same_site_cookie/user_agent_checker.rb, line 29 def missing_same_site_none_support? has_webkit_ss_bug? or drops_unrecognized_ss_cookies? end