@Test(expected = Exception.class) public void urlEncode_withImproperlyEncodedUrlScheme_shouldThowException() throws Exception { urlEncode("https%3A%2F%2Fwww.mywebsite.com%2Fdocs%2Fenglish%2Fsite%2Fmybook.do%3Fkey%3Dvalue%3B%23fragment"); }
public static String urlEncode(@NonNull final String url) throws Exception { Preconditions.checkNotNull(url); if (isUrlImproperlyEncoded(url)) { throw new UnsupportedEncodingException("URL is improperly encoded: " + url); } URI uri; if (isUrlUnencoded(url)) { uri = encodeUrl(url); } else { uri = new URI(url); } return uri.toURL().toString(); }
HttpClient { public static String urlEncode(@NonNull final String url) throws Exception { Preconditions.checkNotNull(url); if (isUrlImproperlyEncoded(url)) { throw new UnsupportedEncodingException("URL is improperly encoded: " + url); } URI uri; if (isUrlUnencoded(url)) { uri = encodeUrl(url); } else { uri = new URI(url); } return uri.toURL().toString(); } }
HttpClient { public static String urlEncode(@NonNull final String url) throws Exception { Preconditions.checkNotNull(url); if (isUrlImproperlyEncoded(url)) { throw new UnsupportedEncodingException("URL is improperly encoded: " + url); } URI uri; if (isUrlUnencoded(url)) { uri = encodeUrl(url); } else { uri = new URI(url); } return uri.toURL().toString(); }  }
HttpClient { public static String urlEncode(@NonNull final String url) throws Exception { Preconditions.checkNotNull(url); if (isUrlImproperlyEncoded(url)) { throw new UnsupportedEncodingException("URL is improperly encoded: " + url); } URI uri; if (isUrlUnencoded(url)) { uri = encodeUrl(url); } else { uri = new URI(url); } return uri.toURL().toString(); }  static AndroidHttpClient getHttpClient(); static HttpGet initializeHttpGet(@NonNull final String url); static HttpGet initializeHttpGet(@NonNull String url, @Nullable final Context context); static String urlEncode(@NonNull final String url); synchronized static String getWebViewUserAgent(String defaultUserAgent); synchronized static String getWebViewUserAgent(); synchronized static void setWebViewUserAgent(final String userAgent); }
HttpClient { public static String urlEncode(@NonNull final String url) throws Exception { Preconditions.checkNotNull(url); if (isUrlImproperlyEncoded(url)) { throw new UnsupportedEncodingException("URL is improperly encoded: " + url); } URI uri; if (isUrlUnencoded(url)) { uri = encodeUrl(url); } else { uri = new URI(url); } return uri.toURL().toString(); }  static AndroidHttpClient getHttpClient(); static HttpGet initializeHttpGet(@NonNull final String url); static HttpGet initializeHttpGet(@NonNull String url, @Nullable final Context context); static String urlEncode(@NonNull final String url); synchronized static String getWebViewUserAgent(String defaultUserAgent); synchronized static String getWebViewUserAgent(); synchronized static void setWebViewUserAgent(final String userAgent);  }