forked from openHPI/xikolo-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser_support.rb
47 lines (39 loc) · 1.07 KB
/
browser_support.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true
class BrowserSupport
def initialize(browser)
@browser = browser
end
##
# A browser that we actively discourage using.
#
def unsupported?
return false if @browser.bot?
return true if @browser.ie?
@browser.edge? && @browser.version.to_i < 119
end
VERSIONS_CONSIDERED_MODERN = {
chrome: 119,
edge: 122,
firefox: 115,
opera: 107,
safari: 17,
}.freeze
##
# A browser that we may not fully support.
#
def old?
return false if @browser.bot?
return true if @browser.ie?
return false if firefox_on_ipad? && (@browser.version.to_i > 68)
VERSIONS_CONSIDERED_MODERN.any? do |browser, minimum|
@browser.send(:"#{browser}?") && @browser.version.to_i < minimum
end
end
private
def firefox_on_ipad?
# Firefox version numbers are different for iOS and
# the browser gem does not detect iPads with iOS 13 as iPad but Mac.
# Thus, we check for platform.mac? in combination with webkit? instead.
@browser.platform.mac? && @browser.webkit? && @browser.firefox?
end
end