public static String prepareUrl(@NonNull String url) {
        url = url.trim();
        String lowerCaseUrl = url.toLowerCase(Locale.ROOT); // protocol names are case insensitive
        if (lowerCaseUrl.startsWith("feed://")) {
            Log.d(TAG, "Replacing feed:// with http://");
            return prepareUrl(url.substring("feed://".length()));
        } else if (lowerCaseUrl.startsWith("pcast://")) {
            Log.d(TAG, "Removing pcast://");
            return prepareUrl(url.substring("pcast://".length()));
        } else if (lowerCaseUrl.startsWith("pcast:")) {
            Log.d(TAG, "Removing pcast:");
            return prepareUrl(url.substring("pcast:".length()));
        } else if (lowerCaseUrl.startsWith("itpc")) {
            Log.d(TAG, "Replacing itpc:// with http://");
            return prepareUrl(url.substring("itpc://".length()));
        } else if (lowerCaseUrl.startsWith(AP_SUBSCRIBE)) {
            Log.d(TAG, "Removing antennapod-subscribe://");
            return prepareUrl(url.substring(AP_SUBSCRIBE.length()));
        } else if (lowerCaseUrl.contains(AP_SUBSCRIBE_DEEPLINK)) {
            Log.d(TAG, "Removing " + AP_SUBSCRIBE_DEEPLINK);
            String query = Uri.parse(url).getQueryParameter("url");
            try {
                return prepareUrl(URLDecoder.decode(query, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                return prepareUrl(query);
            }
        } else if (!(lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://"))) {
            Log.d(TAG, "Adding http:// at the beginning of the URL");
            return "http://" + url;
        } else {
            return url;
        }
    }
@Test
    public void testProtocolRelativeUrlIsAbsolute() {
        final String in = "https://example.com";
        final String inBase = "http://examplebase.com";
        final String out = UrlChecker.prepareUrl(in, inBase);
        assertEquals(in, out);
    }