URLUtils { public static String getQueryStringRemovingParams(HttpServerExchange exchange, String... paramsToRemove) { String ret = exchange.getQueryString(); if (ret == null || ret.isEmpty() || paramsToRemove == null) { return ret; } for (String key : paramsToRemove) { Deque<String> values = exchange.getQueryParameters().get(key); if (values != null) { for (String value : values) { ret = ret.replaceAll(key + "=" + value + "&", ""); ret = ret.replaceAll(key + "=" + value + "$", ""); } } } return ret; }  static String removeTrailingSlashes(String s); static String decodeQueryString(String qs); static String getParentPath(String path); static String getPrefixUrl(HttpServerExchange exchange); static String getQueryStringRemovingParams(HttpServerExchange exchange, String... paramsToRemove); static String getIdString(BsonValue id);  }
@Test public void testGetQueryStringRemovingParams() { HttpServerExchange exchange = new HttpServerExchange(); exchange.setQueryString("a=1&b=2&c=3"); exchange.addQueryParam("a", "1").addQueryParam("b", "2").addQueryParam("c", "3"); String expResult = "a=1&c=3"; String result = URLUtils.getQueryStringRemovingParams(exchange, "b"); assertEquals(expResult, result); }