package cgeo.geocaching.utils;

import cgeo.geocaching.models.Geocache;

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import android.util.Patterns;

import java.util.regex.Matcher;

public final class CheckerUtils {
    private static final String[] CHECKERS = { "geocheck.org/geo_inputchkcoord.php?", "geochecker.com/index.php?", "certitudes.org/certitude?" };

    private CheckerUtils() {
        // utility class
    }

    @Nullable
    public static String getCheckerUrl(@NonNull final Geocache cache) {
        final String description = cache.getDescription();
        final Matcher matcher = Patterns.WEB_URL.matcher(description);
        while (matcher.find()) {
            final String url = matcher.group();
            for (final String checker : CHECKERS) {
                if (StringUtils.containsIgnoreCase(url, checker)) {
                    return StringEscapeUtils.unescapeHtml4(url);
                }
            }
        }
        return null;
    }
}

@@ -70,104 +70,8 @@
 e;%0A%0A
-import org.apache.commons.lang3.StringEscapeUtils;%0Aimport org.apache.commons.lang3.StringUtils;%0A
 impo
@@ -153,17 +153,16 @@
 llable;%0A
-%0A
 import a
@@ -217,16 +217,113 @@
 tcher;%0A%0A
+import org.apache.commons.lang3.StringEscapeUtils;%0Aimport org.apache.commons.lang3.StringUtils;%0A%0A
 public f
@@ -490,16 +490,55 @@
 titude?%22
+, %22geochecker.gps-cache.de/check.aspx?%22
  %7D;%0A%0A   

fix #5837: Checker menu missing