diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f9069d..9a83801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog + +## upcoming +### Changed +- Ignore subscriptions that have no url + ## 3.1.0 - 2021-10-18 ### Changed - Add timestamp to subscription change response @JonOfUs diff --git a/lib/Core/SubscriptionChange/SubscriptionChangesReader.php b/lib/Core/SubscriptionChange/SubscriptionChangesReader.php index e63e122..1066c49 100644 --- a/lib/Core/SubscriptionChange/SubscriptionChangesReader.php +++ b/lib/Core/SubscriptionChange/SubscriptionChangesReader.php @@ -13,6 +13,7 @@ class SubscriptionChangesReader { */ public static function mapToSubscriptionsChanges(array $urls, bool $subscribed): array { $subscriptionChanges = []; + $urls = array_filter($urls, function(string $url) {return filter_var($url, FILTER_VALIDATE_URL) !== false; }); foreach ($urls as $url) { $subscriptionChanges[] = new SubscriptionChange($url, $subscribed); } diff --git a/tests/Unit/Core/SubscriptionChange/SubscriptionChangeReaderTest.php b/tests/Unit/Core/SubscriptionChange/SubscriptionChangeReaderTest.php index 0a47a53..e71dd48 100644 --- a/tests/Unit/Core/SubscriptionChange/SubscriptionChangeReaderTest.php +++ b/tests/Unit/Core/SubscriptionChange/SubscriptionChangeReaderTest.php @@ -14,4 +14,14 @@ class SubscriptionChangeReaderTest extends TestCase { $this->assertSame("https://feeds.megaphone.fm/another", $subscriptionChange[1]->getUrl()); } + + public function testNonUrisAreOmmited(): void { + $subscriptionChange = SubscriptionChangesReader::mapToSubscriptionsChanges([ + "https://feeds.megaphone.fm/HSW8286374095", + "antennapod_local:content://com.android.externalstorage.documents/tree/home:podcast" + ], true); + $this->assertCount(1, $subscriptionChange); + $this->assertSame("https://feeds.megaphone.fm/HSW8286374095", $subscriptionChange[0]->getUrl()); + } + }