summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/de/danoeh/antennapod/util/URLChecker.java4
-rw-r--r--src/instrumentationTest/de/test/antennapod/util/URLCheckerTest.java12
2 files changed, 16 insertions, 0 deletions
diff --git a/src/de/danoeh/antennapod/util/URLChecker.java b/src/de/danoeh/antennapod/util/URLChecker.java
index af0226ce0..9997daaf7 100644
--- a/src/de/danoeh/antennapod/util/URLChecker.java
+++ b/src/de/danoeh/antennapod/util/URLChecker.java
@@ -1,6 +1,9 @@
package de.danoeh.antennapod.util;
import android.util.Log;
+
+import org.apache.commons.lang3.StringUtils;
+
import de.danoeh.antennapod.BuildConfig;
/**
@@ -27,6 +30,7 @@ public final class URLChecker {
*/
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://");
diff --git a/src/instrumentationTest/de/test/antennapod/util/URLCheckerTest.java b/src/instrumentationTest/de/test/antennapod/util/URLCheckerTest.java
index 18e8bf007..91e5d966f 100644
--- a/src/instrumentationTest/de/test/antennapod/util/URLCheckerTest.java
+++ b/src/instrumentationTest/de/test/antennapod/util/URLCheckerTest.java
@@ -43,4 +43,16 @@ public class URLCheckerTest extends AndroidTestCase {
final String out = URLChecker.prepareURL(in);
assertEquals("http://example.com", out);
}
+
+ public void testWhiteSpaceUrlShouldNotAppend() {
+ final String in = "\n http://example.com \t";
+ final String out = URLChecker.prepareURL(in);
+ assertEquals("http://example.com", out);
+ }
+
+ public void testWhiteSpaceShouldAppend() {
+ final String in = "\n example.com \t";
+ final String out = URLChecker.prepareURL(in);
+ assertEquals("http://example.com", out);
+ }
}