Skip to content

Commit

Permalink
FIX: Correctly identify Chromium-based Edge
Browse files Browse the repository at this point in the history
Chromium-based Edge browsers has only "Edg" in user agent string.
  • Loading branch information
pmusaraj committed Jul 29, 2019
1 parent 70bd8e2 commit b570534
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/browser_detection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module BrowserDetection

def self.browser(user_agent)
case user_agent
when /Edge/i
when /Edg/i
:edge
when /Opera/i, /OPR/i
:opera
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/browser_detection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
["Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", :firefox, :linux, :linux],
["Opera/9.80 (X11; Linux zvav; U; en) Presto/2.12.423 Version/12.16", :opera, :linux, :linux],
["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246", :edge, :windows, :windows],
["Mozilla/5.0 (X11; CrOS x86_64 11895.95.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.125 Safari/537.36 ", :chrome, :chromebook, :chromeos]
["Mozilla/5.0 (X11; CrOS x86_64 11895.95.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.125 Safari/537.36 ", :chrome, :chromebook, :chromeos],
["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edg/75.10240", :edge, :windows, :windows]
].each do |user_agent, browser, device, os|
expect(BrowserDetection.browser(user_agent)).to eq(browser)
expect(BrowserDetection.device(user_agent)).to eq(device)
Expand Down

0 comments on commit b570534

Please sign in to comment.