XUrl { public static Map<String, List<String>> decodeQueryString(String url) { Preconditions.checkNotNull(url); QueryStringDecoder decoder = new QueryStringDecoder(rawQueryParameters(url)); Map<String, List<String>> params = new DefaultValueMap<>(ImmutableList.of()); params.putAll(decoder.parameters()); return params; }  static String host(String url); static int port(String url); static String domainChecked(String url); static String path(String url); static String stripUrlParameters(String url); static String stripUrlParameters(URL url); static String rawQueryParameters(String url); static String addProtocol(String url); static Map<String, List<String>> decodeQueryString(String url); static InetSocketAddress inetSocket(String url);  }
@Test void decodeQueryString1() { String query = "https: assertEquals("value1", XUrl.decodeQueryString(query).get("param1").get(0)); assertEquals("value2", XUrl.decodeQueryString(query).get("param2").get(0)); assertEquals("value3", XUrl.decodeQueryString(query).get("param3").get(0)); }
@Test void decodeQueryString2() { String query = "https: assertEquals("value1", XUrl.decodeQueryString(query).get("param1").get(0)); assertEquals("", XUrl.decodeQueryString(query).get("param2").get(0)); assertEquals("value3", XUrl.decodeQueryString(query).get("param3").get(0)); assertEquals("", XUrl.decodeQueryString(query).get("param3").get(1)); }
@Test void decodeQueryString_withUrlEncoding() { String query = "https: assertEquals("value 1", XUrl.decodeQueryString(query).get("param1").get(0)); assertEquals("", XUrl.decodeQueryString(query).get("param2").get(0)); assertEquals("value 3", XUrl.decodeQueryString(query).get("param3").get(0)); assertEquals("", XUrl.decodeQueryString(query).get("param3").get(1)); }
@Test void decodeQueryString3() { String noPath = "https: String noPathTrailingSlash = "https: assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(noPath).get("param1").get(0)); assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(noPathTrailingSlash).get("param2").get(0)); assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(noPathTrailingSlash).get("param2").get(0)); String noPathQuery = "https: assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(noPathQuery).get("param3").get(0)); String withPathNoQuery = "https: assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(withPathNoQuery).get("param3").get(1)); String withPathTrailingSlashNoQuery = "https: assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(withPathTrailingSlashNoQuery).get("param3").get(1)); String withPathTrailingSlash = "https: assertThrows( IndexOutOfBoundsException.class, () -> XUrl.decodeQueryString(withPathTrailingSlash).get("param3").get(1)); }