30 Debug.Log($
"Parsing URL Arguments {url}");
31 string urlData = url.Substring(url.IndexOf(
'?') + 1);
33 if (urlData.Length <= 0)
35 Debug.Log(
"No ? found in the url.");
39 Dictionary<string, string> parameters =
new Dictionary<string, string>();
42 string[] optionalDataSplit = urlData.Split(
"optional=");
43 if (optionalDataSplit.Length > 1)
45 Debug.Log($
"Optional data parts {optionalDataSplit[0]} -- {optionalDataSplit[1]}");
46 string optionalData = optionalDataSplit[1];
47 int jsonEndPosition = optionalData.LastIndexOf(
'}');
48 string isolatedOptionalData = optionalData.Substring(0, jsonEndPosition + 1);
49 Debug.Log($
"Isolated data: {isolatedOptionalData}");
50 parameters.Add(
"optional", isolatedOptionalData);
52 if(jsonEndPosition < optionalData.Length - 1)
54 string otherData = optionalData.Substring(jsonEndPosition + 1);
55 Debug.Log($
"Other data: {otherData}");
56 string baseData = optionalDataSplit[0];
57 if (baseData.Length > 0 && baseData.EndsWith(
'&'))
59 baseData = baseData.Remove(baseData.Length - 1, 1);
61 urlData = baseData + otherData;
62 Debug.Log($
"Combined url: {urlData}");
66 string[] dataArray = urlData.Split(
'&');
68 if (dataArray.Length <= 0)
70 Debug.Log(
"No arguments found on the url.");
74 foreach (
string dataElement
in dataArray)
76 Debug.Log($
"Parsing: {dataElement}");
77 string[] dataParts = dataElement.Split(
'=', 2);
79 if (dataParts.Length <= 1)
81 Debug.Log($
"No named argument.");
85 Debug.Log($
"Found argument {dataParts[0]} - {dataParts[1]}");
86 parameters.Add(dataParts[0], dataParts[1]);