Support subscribe links that have a slash before the argument

This commit is contained in:
ByteHamster 2021-10-31 11:21:28 +01:00
parent 31c0f90d07
commit b1eda19a73
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="