]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/util/Util.java
Reformat imports
[signal-cli] / src / main / java / org / asamk / signal / util / Util.java
index 93a595d1e73865e1d59b43e36e088437f0708028..f0d39601bf2298c709797672f6f6f82e42e8cef5 100644 (file)
@@ -2,11 +2,11 @@ package org.asamk.signal.util;
 
 import com.fasterxml.jackson.databind.JsonNode;
 
+import org.asamk.signal.GroupIdFormatException;
+import org.whispersystems.signalservice.internal.util.Base64;
+
+import java.io.IOException;
 import java.io.InvalidObjectException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.HashMap;
-import java.util.Map;
 
 public class Util {
 
@@ -23,28 +23,6 @@ public class Util {
         return f.toString();
     }
 
-    public static Map<String, String> getQueryMap(String query) {
-        String[] params = query.split("&");
-        Map<String, String> map = new HashMap<>();
-        for (String param : params) {
-            String name = null;
-            final String[] paramParts = param.split("=");
-            try {
-                name = URLDecoder.decode(paramParts[0], "utf-8");
-            } catch (UnsupportedEncodingException e) {
-                // Impossible
-            }
-            String value = null;
-            try {
-                value = URLDecoder.decode(paramParts[1], "utf-8");
-            } catch (UnsupportedEncodingException e) {
-                // Impossible
-            }
-            map.put(name, value);
-        }
-        return map;
-    }
-
     public static String join(CharSequence separator, Iterable<? extends CharSequence> list) {
         StringBuilder buf = new StringBuilder();
         for (CharSequence str : list) {
@@ -65,4 +43,12 @@ public class Util {
 
         return node;
     }
+
+    public static byte[] decodeGroupId(String groupId) throws GroupIdFormatException {
+        try {
+            return Base64.decode(groupId);
+        } catch (IOException e) {
+            throw new GroupIdFormatException(groupId, e);
+        }
+    }
 }