From 8aa5df69f0eb4cdd3d1d8390cc607d9006744103 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Fri, 9 Aug 2019 11:56:48 +0300 Subject: [PATCH] FIX: Detect DiscourseHub user agent. It used to show up as an unknown device and browser in user preferences (Recently Used Devices). --- lib/browser_detection.rb | 4 ++-- spec/lib/browser_detection_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/browser_detection.rb b/lib/browser_detection.rb index f2e863994da..e2f8d46a88a 100644 --- a/lib/browser_detection.rb +++ b/lib/browser_detection.rb @@ -16,7 +16,7 @@ module BrowserDetection :safari when /MSIE/i, /Trident/i :ie - when /DiscourseHub/i + when /Discourse/i :discoursehub else :unknown @@ -54,7 +54,7 @@ module BrowserDetection :android when /CrOS/i :chromeos - when /iPhone|iPad|iPod/i + when /iPhone|iPad|iPod|Darwin/i :ios when /Macintosh/i :macos diff --git a/spec/lib/browser_detection_spec.rb b/spec/lib/browser_detection_spec.rb index afeb8e96fee..b6faa54f113 100644 --- a/spec/lib/browser_detection_spec.rb +++ b/spec/lib/browser_detection_spec.rb @@ -31,7 +31,8 @@ describe BrowserDetection do ["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 (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] + ["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], + ["Discourse/163 CFNetwork/978.0.7 Darwin/18.6.0", :discoursehub, :unknown, :ios] ].each do |user_agent, browser, device, os| expect(BrowserDetection.browser(user_agent)).to eq(browser) expect(BrowserDetection.device(user_agent)).to eq(device)