mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-29 06:38:51 +03:00
[FirefoxAddonsBridge] Fix removal of link redirects (#3144)
* [FirefoxAddonsBridge] Fix removable of link redirects * Update FirefoxAddonsBridge.php
This commit is contained in:
parent
80f9871c9e
commit
734a5868b8
1 changed files with 6 additions and 3 deletions
|
@ -21,7 +21,7 @@ class FirefoxAddonsBridge extends BridgeAbstract
|
||||||
private $feedName = '';
|
private $feedName = '';
|
||||||
private $releaseDateRegex = '/Released ([\w, ]+) - ([\w. ]+)/';
|
private $releaseDateRegex = '/Released ([\w, ]+) - ([\w. ]+)/';
|
||||||
private $xpiFileRegex = '/([A-Za-z0-9_.-]+)\.xpi$/';
|
private $xpiFileRegex = '/([A-Za-z0-9_.-]+)\.xpi$/';
|
||||||
private $outgoingRegex = '/https:\/\/outgoing.prod.mozaws.net\/v1\/(?:[A-z0-9]+)\//';
|
private $outgoingRegex = '/https:\/\/prod.outgoing\.prod\.webservices\.mozgcp\.net\/v1\/(?:[A-z0-9]+)\//';
|
||||||
|
|
||||||
private $urlRegex = '/addons\.mozilla\.org\/(?:[\w-]+\/)?firefox\/addon\/([\w-]+)/';
|
private $urlRegex = '/addons\.mozilla\.org\/(?:[\w-]+\/)?firefox\/addon\/([\w-]+)/';
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class FirefoxAddonsBridge extends BridgeAbstract
|
||||||
$downloadlink = $li->find('a.Button.Button--action.AMInstallButton-button.Button--puffy', 0)->href;
|
$downloadlink = $li->find('a.Button.Button--action.AMInstallButton-button.Button--puffy', 0)->href;
|
||||||
}
|
}
|
||||||
|
|
||||||
$releaseNotes = $this->removeOutgoinglink($li->find('div.AddonVersionCard-releaseNotes', 0));
|
$releaseNotes = $this->removeLinkRedirects($li->find('div.AddonVersionCard-releaseNotes', 0));
|
||||||
|
|
||||||
if (preg_match($this->xpiFileRegex, $downloadlink, $match)) {
|
if (preg_match($this->xpiFileRegex, $downloadlink, $match)) {
|
||||||
$xpiFilename = $match[0];
|
$xpiFilename = $match[0];
|
||||||
|
@ -105,7 +105,10 @@ EOD;
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function removeOutgoinglink($html)
|
/**
|
||||||
|
* Removes 'https://prod.outgoing.prod.webservices.mozgcp.net/v1/' from external links
|
||||||
|
*/
|
||||||
|
private function removeLinkRedirects($html)
|
||||||
{
|
{
|
||||||
foreach ($html->find('a') as $a) {
|
foreach ($html->find('a') as $a) {
|
||||||
$a->href = urldecode(preg_replace($this->outgoingRegex, '', $a->href));
|
$a->href = urldecode(preg_replace($this->outgoingRegex, '', $a->href));
|
||||||
|
|
Loading…
Reference in a new issue