aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2013-12-30 19:27:46 +0100
committerBananeweizen <Bananeweizen@gmx.de>2013-12-30 19:27:46 +0100
commit508c170bb57c157dea31215b38e6660435baf93a (patch)
tree9d15a999742b8c2b9c908d1542baf66d8a489603
parent8dcb0e32fc92d0fc81c3f7e708ff6e175458ba8c (diff)
downloadcgeo-508c170bb57c157dea31215b38e6660435baf93a.zip
cgeo-508c170bb57c157dea31215b38e6660435baf93a.tar.gz
cgeo-508c170bb57c157dea31215b38e6660435baf93a.tar.bz2
fix #3493: search by geocode for EC is case sensitive
-rw-r--r--main/src/cgeo/geocaching/connector/ec/ECApi.java6
-rw-r--r--tests/src/cgeo/geocaching/connector/ec/ECApiTest.java12
2 files changed, 15 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/connector/ec/ECApi.java b/main/src/cgeo/geocaching/connector/ec/ECApi.java
index 9f758b0..94936e4 100644
--- a/main/src/cgeo/geocaching/connector/ec/ECApi.java
+++ b/main/src/cgeo/geocaching/connector/ec/ECApi.java
@@ -40,12 +40,12 @@ public class ECApi {
private static final FastDateFormat LOG_DATE_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSSZ", TimeZone.getTimeZone("UTC"), Locale.US);
- public static String cleanCode(String geocode) {
- return geocode.replace("EC", "");
+ public static String getIdFromGeocode(final String geocode) {
+ return StringUtils.removeStartIgnoreCase(geocode, "EC");
}
public static Geocache searchByGeoCode(final String geocode) {
- final Parameters params = new Parameters("id", cleanCode(geocode));
+ final Parameters params = new Parameters("id", getIdFromGeocode(geocode));
final HttpResponse response = apiRequest("gpx.php", params);
final Collection<Geocache> caches = importCachesFromGPXResponse(response);
diff --git a/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java b/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java
new file mode 100644
index 0000000..9f9e99c
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/ec/ECApiTest.java
@@ -0,0 +1,12 @@
+package cgeo.geocaching.connector.ec;
+
+import junit.framework.TestCase;
+
+public class ECApiTest extends TestCase {
+
+ public static void testGetIdFromGeocode() throws Exception {
+ assertEquals("242", ECApi.getIdFromGeocode("EC242"));
+ assertEquals("242", ECApi.getIdFromGeocode("ec242"));
+ }
+
+}