@Test void preserveParameterOrder() { EscapeTool escapeTool = new EscapeTool(); String queryString = "x=5&x=4&r=3&a=2"; assertEquals(queryString, escapeTool.url(tool.parseQuery(queryString))); }
public Map<String, List<String>> parseQuery(String query) { Map<String, List<String>> queryParams = new LinkedHashMap<>(); if (query != null) { for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) { String name = params.getName(); List<String> values = queryParams.get(name); if (values == null) { values = new ArrayList<>(); queryParams.put(name, values); } values.add(params.getValue()); } } return queryParams; }
URLTool { public Map<String, List<String>> parseQuery(String query) { Map<String, List<String>> queryParams = new LinkedHashMap<>(); if (query != null) { for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) { String name = params.getName(); List<String> values = queryParams.get(name); if (values == null) { values = new ArrayList<>(); queryParams.put(name, values); } values.add(params.getValue()); } } return queryParams; } }
URLTool { public Map<String, List<String>> parseQuery(String query) { Map<String, List<String>> queryParams = new LinkedHashMap<>(); if (query != null) { for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) { String name = params.getName(); List<String> values = queryParams.get(name); if (values == null) { values = new ArrayList<>(); queryParams.put(name, values); } values.add(params.getValue()); } } return queryParams; }  }
URLTool { public Map<String, List<String>> parseQuery(String query) { Map<String, List<String>> queryParams = new LinkedHashMap<>(); if (query != null) { for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) { String name = params.getName(); List<String> values = queryParams.get(name); if (values == null) { values = new ArrayList<>(); queryParams.put(name, values); } values.add(params.getValue()); } } return queryParams; }  Map<String, List<String>> parseQuery(String query); }
URLTool { public Map<String, List<String>> parseQuery(String query) { Map<String, List<String>> queryParams = new LinkedHashMap<>(); if (query != null) { for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) { String name = params.getName(); List<String> values = queryParams.get(name); if (values == null) { values = new ArrayList<>(); queryParams.put(name, values); } values.add(params.getValue()); } } return queryParams; }  Map<String, List<String>> parseQuery(String query);  }