-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ def match? | |
!miui_browser? && | ||
!maxthon? && | ||
!qq? && | ||
!sougou_browser? && | ||
!google_search_app? | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ def match? | |
!maxthon? && | ||
!qq? && | ||
!alipay? && | ||
!sougou_browser? && | ||
!google_search_app? | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Browser | ||
class SougouBrowser < Base | ||
def id | ||
:sougou_browser | ||
end | ||
|
||
def name | ||
"Sougou Browser" | ||
end | ||
|
||
# We can't get the real version on desktop device from the ua string | ||
def full_version | ||
ua[%r{(?:SogouMobileBrowser)/([\d.]+)}, 1] || "0.0" | ||
end | ||
|
||
# SogouMobileBrowser for mobile device | ||
# SE for desktop device | ||
def match? | ||
ua =~ /SogouMobileBrowser/i || ua =~ / SE / | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class SougouBrowserTest < Minitest::Test | ||
test "detects Sougou Browser on desktop device" do | ||
browser = Browser.new(Browser["SOUGOU_BROWSER"]) | ||
assert browser.sougou_browser? | ||
refute browser.safari? | ||
refute browser.chrome? | ||
assert_equal "Sougou Browser", browser.name | ||
assert_equal :sougou_browser, browser.id | ||
end | ||
|
||
test "detects correct version on desktop device" do | ||
browser = Browser.new(Browser["SOUGOU_BROWSER"]) | ||
assert_equal "0.0", browser.full_version | ||
assert_equal "0", browser.version | ||
end | ||
|
||
test "detects Sougou Browser on mobile device" do | ||
browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"]) | ||
assert browser.sougou_browser? | ||
assert browser.device.mobile? | ||
refute browser.safari? | ||
refute browser.chrome? | ||
assert_equal "Sougou Browser", browser.name | ||
assert_equal :sougou_browser, browser.id | ||
end | ||
|
||
test "detects correct version on mobile device" do | ||
browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"]) | ||
assert_equal "5.28.12", browser.full_version | ||
assert_equal "5", browser.version | ||
end | ||
|
||
test "detects version by range on mobile device" do | ||
browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"]) | ||
assert browser.sougou_browser?(%w[>=5 <6]) | ||
end | ||
end |