Remove leading and trailing whitespace in URLChecker. fixes #461
This commit is contained in:
parent
f59623bb94
commit
74294bad55
|
@ -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://");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue