From 6eef3d4516daa2807995af32d61f2513f9e2f321 Mon Sep 17 00:00:00 2001 From: Louis Barthonet Date: Wed, 25 Oct 2023 15:22:15 +0100 Subject: [PATCH 1/2] feat: add support for Ecosia iOS & Ecosia Android --- regexes.yaml | 6 ++++++ tests/test_ua.yaml | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/regexes.yaml b/regexes.yaml index a8f8e097..cc475fbc 100644 --- a/regexes.yaml +++ b/regexes.yaml @@ -457,6 +457,12 @@ user_agent_parsers: - regex: '(Tenta/)(\d+)\.(\d+)\.(\d+)' family_replacement: 'Tenta Browser' + # Ecosia on iOS / Android + - regex: '(Ecosia) ios@(\d+)\.(\d+)\.(\d+)\.(\d+)' + family_replacement: 'Ecosia iOS' + - regex: '(Ecosia) android@(\d+)\.(\d+)\.(\d+)\.(\d+)' + family_replacement: 'Ecosia Android' + # Chrome Mobile - regex: 'Version/.{1,300}(Chrome)/(\d+)\.(\d+)\.(\d+)\.(\d+)' family_replacement: 'Chrome Mobile WebView' diff --git a/tests/test_ua.yaml b/tests/test_ua.yaml index 2b2bee8c..82edc67c 100644 --- a/tests/test_ua.yaml +++ b/tests/test_ua.yaml @@ -8681,3 +8681,15 @@ test_cases: major: '3' minor: '2' patch: '1' + + - user_agent_string: 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Safari/605.1.15 (Ecosia ios@8.1.3.72)' + family: 'Ecosia iOS' + major: '8' + minor: '1' + patch: '3' + + - user_agent_string: 'Mozilla/5.0 (Linux; Android 9; Redmi 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Mobile Safari/537.36 (Ecosia android@101.0.4951.41)' + family: 'Ecosia Android' + major: '101' + minor: '0' + patch: '4951' \ No newline at end of file From d7d11c8bd4121fcd06603e4f5c63c693db85bd42 Mon Sep 17 00:00:00 2001 From: Louis Barthonet Date: Wed, 25 Oct 2023 15:28:39 +0100 Subject: [PATCH 2/2] fix: ensure regex for Phantom on Android matches the string properly With how the regex was written before, it was matching either Phantom/ios or android, instead of Phantom/android. The test worked as expected, but this broke the newly introduced test for Ecosia, as it would match aswell. --- regexes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regexes.yaml b/regexes.yaml index cc475fbc..e6855d5e 100644 --- a/regexes.yaml +++ b/regexes.yaml @@ -217,7 +217,7 @@ user_agent_parsers: family_replacement: 'Twitter' # Phantom app - - regex: 'Mozilla.{1,200}Mobile.{1,100}(Phantom\/ios|android).(\d+)\.(\d+)\.(\d+)' + - regex: 'Mozilla.{1,200}Mobile.{1,100}(Phantom\/ios|Phantom\/android).(\d+)\.(\d+)\.(\d+)' family_replacement: 'Phantom' # aspiegel.com spider (owned by Huawei, later called PetalBot)