From 99b43f281bd912b14ff1c3cf33dffe470dca2f07 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Mon, 22 Oct 2018 15:15:41 +0300 Subject: [PATCH] FIX: Fix browser detection for Microsoft Edge. (#6516) cool! --- config/locales/server.en.yml | 1 + lib/browser_detection.rb | 2 ++ spec/lib/browser_detection_spec.rb | 1 + 3 files changed, 4 insertions(+) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 651b276d7f2..f38a823a6cd 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -709,6 +709,7 @@ en: firefox: "Firefox" opera: "Opera" ie: "Internet Explorer" + edge: "Microsoft Edge" unknown: "unknown browser" device: android: "Android Device" diff --git a/lib/browser_detection.rb b/lib/browser_detection.rb index cf3ea57e6ae..78d5bd11614 100644 --- a/lib/browser_detection.rb +++ b/lib/browser_detection.rb @@ -2,6 +2,8 @@ module BrowserDetection def self.browser(user_agent) case user_agent + when /Edge/i + :edge when /Opera/i, /OPR/i :opera when /Firefox/i diff --git a/spec/lib/browser_detection_spec.rb b/spec/lib/browser_detection_spec.rb index 6a4722ca741..f67a7c07072 100644 --- a/spec/lib/browser_detection_spec.rb +++ b/spec/lib/browser_detection_spec.rb @@ -27,6 +27,7 @@ describe BrowserDetection do ["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36", :chrome, :linux, :linux], ["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], ].each do |user_agent, browser, device, os| expect(BrowserDetection.browser(user_agent)).to eq(browser) expect(BrowserDetection.device(user_agent)).to eq(device)