Skip to content

Commit 6cc364a

Browse files
committed
feat: resolved PR comments.
Signed-off-by: Gaurav Goel <[email protected]>
1 parent 329c6f6 commit 6cc364a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Assets/Plugins/Web3AuthSDK/Web3Auth.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,14 @@ public void setResultUrl(Uri uri)
374374
throw new UserCancelledException();
375375
#endif
376376
hash = hash.Remove(0, 1);
377-
Dictionary<string, string> queryParameters = Utils.ParseQuery(uri.Query);
378377

378+
Dictionary<string, string> queryParameters = Utils.ParseQuery(uri.Query);
379379
if (queryParameters.Keys.Contains("error"))
380380
throw new UnKnownException(queryParameters["error"]);
381381

382-
string b64Params = hash.Split('=')[1];
382+
string newUriString = "http://" + uri.Host + "?" + hash;
383+
Uri newUri = new Uri(newUriString);
384+
string b64Params = getQueryParamValue(newUri, "b64Params");
383385
string decodedString = decodeBase64Params(b64Params);
384386
SessionResponse sessionResponse = null;
385387
try
@@ -404,6 +406,25 @@ public void setResultUrl(Uri uri)
404406
#endif
405407
}
406408

409+
private string getQueryParamValue(Uri uri, string key)
410+
{
411+
string value = "";
412+
if (uri.Query != null && uri.Query.Length > 0)
413+
{
414+
string[] queryParameters = uri.Query.Substring(1).Split('&');
415+
foreach (string queryParameter in queryParameters)
416+
{
417+
string[] keyValue = queryParameter.Split('=');
418+
if (keyValue[0] == key)
419+
{
420+
value = keyValue[1];
421+
break;
422+
}
423+
}
424+
}
425+
return value;
426+
}
427+
407428
private string decodeBase64Params(string base64Params)
408429
{
409430
if(string.IsNullOrEmpty(base64Params))

0 commit comments

Comments
 (0)