diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2020-05-21 19:40:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 19:40:40 +0200 |
commit | 8556945427fe58adea47228ac0c4833b113f4b10 (patch) | |
tree | 7b9a35a5632233f8fad6f8574d7612c3b5ab4649 | |
parent | 339fc1a04beef555d7058aef8e54c1c76e7a9fcd (diff) | |
parent | a02db6e70517d572a966ef221e2d4fe75b753d09 (diff) | |
download | AntennaPod-8556945427fe58adea47228ac0c4833b113f4b10.zip |
Merge pull request #4179 from ByteHamster/upper-case-url-scheme
URL schemes are case insensitive
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java b/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java index dbdb37c3b..e1dffef97 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/URLChecker.java @@ -38,22 +38,23 @@ public final class URLChecker { */ public static String prepareURL(@NonNull String url) { url = url.trim(); - if (url.startsWith("feed://")) { + String lowerCaseUrl = url.toLowerCase(); // protocol names are case insensitive + if (lowerCaseUrl.startsWith("feed://")) { if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://"); return url.replaceFirst("feed://", "http://"); - } else if (url.startsWith("pcast://")) { + } else if (lowerCaseUrl.startsWith("pcast://")) { if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast://"); return prepareURL(url.substring("pcast://".length())); - } else if (url.startsWith("pcast:")) { + } else if (lowerCaseUrl.startsWith("pcast:")) { if (BuildConfig.DEBUG) Log.d(TAG, "Removing pcast:"); return prepareURL(url.substring("pcast:".length())); - } else if (url.startsWith("itpc")) { + } else if (lowerCaseUrl.startsWith("itpc")) { if (BuildConfig.DEBUG) Log.d(TAG, "Replacing itpc:// with http://"); return url.replaceFirst("itpc://", "http://"); - } else if (url.startsWith(AP_SUBSCRIBE)) { + } else if (lowerCaseUrl.startsWith(AP_SUBSCRIBE)) { if (BuildConfig.DEBUG) Log.d(TAG, "Removing antennapod-subscribe://"); return prepareURL(url.substring(AP_SUBSCRIBE.length())); - } else if (!(url.startsWith("http://") || url.startsWith("https://"))) { + } else if (!(lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://"))) { if (BuildConfig.DEBUG) Log.d(TAG, "Adding http:// at the beginning of the URL"); return "http://" + url; } else { |