diff --git a/pom.xml b/pom.xml
index c10f38a..6369a2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -180,11 +180,6 @@
jsonld-common-java
1.10.0
-
- org.apache.httpcomponents
- httpclient
- 4.5.14
-
commons-codec
commons-codec
diff --git a/src/main/java/foundation/identity/did/DIDURL.java b/src/main/java/foundation/identity/did/DIDURL.java
index c431ef1..c2028df 100644
--- a/src/main/java/foundation/identity/did/DIDURL.java
+++ b/src/main/java/foundation/identity/did/DIDURL.java
@@ -8,15 +8,15 @@
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.utils.URLEncodedUtils;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.net.URI;
+import java.net.URL;
+import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class DIDURL {
@@ -116,7 +116,10 @@ public void postBranch(int offset, int length) {
String fragment = parsedStrings[5] == null ? null : parsedStrings[5];
DID did = didString == null ? null : new DID(didString, methodName, methodSpecificId, null);
- Map parameters = query == null ? null : URLEncodedUtils.parse(query, StandardCharsets.UTF_8).stream().collect(Collectors.toMap(NameValuePair::getName, NameValuePair::getValue));
+ URI uri;
+ URL url;
+
+ Map parameters = query == null ? null : parseQuerySingle(query);
return new DIDURL(didUrlString, did, path, query, parameters, fragment, parseTree);
} catch (ParserException ex) {
@@ -146,6 +149,26 @@ public static DIDURL fromUri(URI uri, boolean keepParseTree) throws IllegalArgum
* Helper methods
*/
+ private static Map parseQuerySingle(String query) {
+ return Pattern.compile("&")
+ .splitAsStream(query)
+ .map(s -> Arrays.copyOf(s.split("=", 2), 2))
+ .collect(Collectors.toMap(s -> decode(s[0]), s -> decode(s[1])));
+ }
+
+ private static Map> parseQueryMulti(String query) {
+ return Pattern.compile("&")
+ .splitAsStream(query)
+ .map(s -> Arrays.copyOf(s.split("=", 2), 2))
+ .collect(Collectors.groupingBy(s -> decode(s[0]), Collectors.mapping(s -> decode(s[1]), Collectors.toList())));
+ }
+
+ private static String decode(final String encoded) {
+ return Optional.ofNullable(encoded)
+ .map(e -> URLDecoder.decode(e, StandardCharsets.UTF_8))
+ .orElse(null);
+ }
+
public URI toUri() {
return URI.create(this.getDidUrlString());
}