Merge pull request #5513 from ByteHamster/subscribe-link

Support subscribe links that have a slash before the argument
This commit is contained in:
ByteHamster 2021-10-31 21:18:44 +01:00 committed by GitHub
commit d9bf519708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -29,7 +29,7 @@ public final class URLChecker {
private static final String TAG = "URLChecker";
private static final String AP_SUBSCRIBE = "antennapod-subscribe://";
private static final String AP_SUBSCRIBE_DEEPLINK = "antennapod.org/deeplink/subscribe?url=";
private static final String AP_SUBSCRIBE_DEEPLINK = "antennapod.org/deeplink/subscribe";
/**
* Checks if URL is valid and modifies it if necessary.
@ -57,7 +57,7 @@ public final class URLChecker {
return prepareURL(url.substring(AP_SUBSCRIBE.length()));
} else if (lowerCaseUrl.contains(AP_SUBSCRIBE_DEEPLINK)) {
Log.d(TAG, "Removing " + AP_SUBSCRIBE_DEEPLINK);
String removedWebsite = url.substring(url.indexOf(AP_SUBSCRIBE_DEEPLINK) + AP_SUBSCRIBE_DEEPLINK.length());
String removedWebsite = url.substring(url.indexOf("?url=") + "?url=".length());
try {
return prepareURL(URLDecoder.decode(removedWebsite, "UTF-8"));
} catch (UnsupportedEncodingException e) {

View File

@ -106,8 +106,10 @@ public class URLCheckerTest {
final String feed = "http://example.org/podcast.rss";
assertEquals(feed, URLChecker.prepareURL("https://antennapod.org/deeplink/subscribe?url=" + feed));
assertEquals(feed, URLChecker.prepareURL("http://antennapod.org/deeplink/subscribe?url=" + feed));
assertEquals(feed, URLChecker.prepareURL("http://antennapod.org/deeplink/subscribe/?url=" + feed));
assertEquals(feed, URLChecker.prepareURL("https://www.antennapod.org/deeplink/subscribe?url=" + feed));
assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe?url=" + feed));
assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe/?url=" + feed));
assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe?url="
+ URLEncoder.encode(feed, "UTF-8")));
assertEquals(feed, URLChecker.prepareURL("http://www.antennapod.org/deeplink/subscribe?url="