summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-10-08 21:05:01 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2014-10-09 17:09:35 +0200
commite121e98234507925650888e3867173f77f684d98 (patch)
treec97b069553ee0296193af02052fb1a59436cdc25 /src/de/danoeh/antennapod
parenta0365969a01e65d5373f463daea4c9529a6cafe0 (diff)
downloadAntennaPod-e121e98234507925650888e3867173f77f684d98.zip
Added antennapod-subscribe:// subscription scheme
Diffstat (limited to 'src/de/danoeh/antennapod')
-rw-r--r--src/de/danoeh/antennapod/util/URLChecker.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/de/danoeh/antennapod/util/URLChecker.java b/src/de/danoeh/antennapod/util/URLChecker.java
index 9997daaf7..2352adddf 100644
--- a/src/de/danoeh/antennapod/util/URLChecker.java
+++ b/src/de/danoeh/antennapod/util/URLChecker.java
@@ -22,6 +22,8 @@ public final class URLChecker {
*/
private static final String TAG = "URLChecker";
+ private static final String AP_SUBSCRIBE = "antennapod-subscribe://";
+
/**
* Checks if URL is valid and modifies it if necessary.
*
@@ -29,23 +31,24 @@ public final class URLChecker {
* @return The prepared url
*/
public static String prepareURL(String url) {
- StringBuilder builder = new StringBuilder();
url = StringUtils.trim(url);
if (url.startsWith("feed://")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://");
- url = url.replaceFirst("feed://", "http://");
+ return url.replaceFirst("feed://", "http://");
} else if (url.startsWith("pcast://")) {
- if (BuildConfig.DEBUG) Log.d(TAG, "Replacing pcast:// with http://");
- url = url.replaceFirst("pcast://", "http://");
+ if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast://");
+ return prepareURL(StringUtils.removeStart(url, "pcast://"));
} else if (url.startsWith("itpc")) {
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing itpc:// with http://");
- url = url.replaceFirst("itpc://", "http://");
+ return url.replaceFirst("itpc://", "http://");
+ } else if (url.startsWith(AP_SUBSCRIBE)) {
+ if (BuildConfig.DEBUG) Log.d(TAG, "Removing antennapod-subscribe://");
+ return prepareURL(StringUtils.removeStart(url, AP_SUBSCRIBE));
} else if (!(url.startsWith("http://") || url.startsWith("https://"))) {
if (BuildConfig.DEBUG) Log.d(TAG, "Adding http:// at the beginning of the URL");
- builder.append("http://");
+ return "http://" + url;
+ } else {
+ return url;
}
- builder.append(url);
-
- return builder.toString();
}
}