From f633c39ec45bf54027580d5316d4167f75d6992a Mon Sep 17 00:00:00 2001 From: Joseph Date: Thu, 25 Feb 2021 12:27:12 +0000 Subject: [PATCH 1/3] [FirefoxAddonsBridge] Add detectParameters() Adds detectParameters method. --- bridges/FirefoxAddonsBridge.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bridges/FirefoxAddonsBridge.php b/bridges/FirefoxAddonsBridge.php index d9803b74367..ee20f98d3e3 100644 --- a/bridges/FirefoxAddonsBridge.php +++ b/bridges/FirefoxAddonsBridge.php @@ -21,6 +21,19 @@ class FirefoxAddonsBridge extends BridgeAbstract { private $xpiFileRegex = '/([A-Za-z0-9_.-]+)\.xpi$/'; private $outgoingRegex = '/https:\/\/outgoing.prod.mozaws.net\/v1\/(?:[A-z0-9]+)\//'; + private $urlRegex = '/addons\.mozilla\.org\/[\w-]+\/firefox\/addon\/([\w-]+)/'; + + public function detectParameters($url) { + $params = array(); + + if(preg_match($this->urlRegex, $url, $matches)) { + $params['id'] = $matches[1]; + return $params; + } + + return null; + } + public function collectData() { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request: ' . $this->getURI()); From 6f350452cabb2d41f562269f84fe8c8d4ea43e99 Mon Sep 17 00:00:00 2001 From: Joseph Date: Thu, 25 Feb 2021 12:34:09 +0000 Subject: [PATCH 2/3] [FirefoxAddonsBridge] Remove whitespace --- bridges/FirefoxAddonsBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/FirefoxAddonsBridge.php b/bridges/FirefoxAddonsBridge.php index ee20f98d3e3..a5eec9de9fc 100644 --- a/bridges/FirefoxAddonsBridge.php +++ b/bridges/FirefoxAddonsBridge.php @@ -33,7 +33,7 @@ public function detectParameters($url) { return null; } - + public function collectData() { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request: ' . $this->getURI()); From de6415183f08ba33544ae7e2b79d60a89d72f92b Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 28 Feb 2021 14:17:48 +0000 Subject: [PATCH 3/3] [FirefoxAddonsBridge] Update URL regex to handle no locale --- bridges/FirefoxAddonsBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/FirefoxAddonsBridge.php b/bridges/FirefoxAddonsBridge.php index a5eec9de9fc..3592a2c632e 100644 --- a/bridges/FirefoxAddonsBridge.php +++ b/bridges/FirefoxAddonsBridge.php @@ -21,7 +21,7 @@ class FirefoxAddonsBridge extends BridgeAbstract { private $xpiFileRegex = '/([A-Za-z0-9_.-]+)\.xpi$/'; private $outgoingRegex = '/https:\/\/outgoing.prod.mozaws.net\/v1\/(?:[A-z0-9]+)\//'; - private $urlRegex = '/addons\.mozilla\.org\/[\w-]+\/firefox\/addon\/([\w-]+)/'; + private $urlRegex = '/addons\.mozilla\.org\/(?:[\w-]+\/)?firefox\/addon\/([\w-]+)/'; public function detectParameters($url) { $params = array();