35 Debug.Log($
"Parsing URL Arguments {url}");
36 string urlData = url.Substring(url.IndexOf(
'?') + 1);
38 if (urlData.Length <= 0)
40 Debug.Log(
"No ? found in the url.");
44 Dictionary<string, string> parameters =
new Dictionary<string, string>();
47 string[] optionalDataSplit = urlData.Split(
"optional=");
48 if (optionalDataSplit.Length > 1)
50 Debug.Log($
"Optional data parts {optionalDataSplit[0]} -- {optionalDataSplit[1]}");
51 string optionalData = optionalDataSplit[1];
52 int jsonEndPosition = optionalData.LastIndexOf(
'}');
53 string isolatedOptionalData = optionalData.Substring(0, jsonEndPosition + 1);
54 Debug.Log($
"Isolated data: {isolatedOptionalData}");
55 parameters.Add(
"optional", isolatedOptionalData);
57 if(jsonEndPosition < optionalData.Length - 1)
59 string otherData = optionalData.Substring(jsonEndPosition + 1);
60 Debug.Log($
"Other data: {otherData}");
61 string baseData = optionalDataSplit[0];
62 if (baseData.Length > 0 && baseData.EndsWith(
'&'))
64 baseData = baseData.Remove(baseData.Length - 1, 1);
66 urlData = baseData + otherData;
67 Debug.Log($
"Combined url: {urlData}");
71 string[] dataArray = urlData.Split(
'&');
73 if (dataArray.Length <= 0)
75 Debug.Log(
"No arguments found on the url.");
79 foreach (
string dataElement
in dataArray)
81 Debug.Log($
"Parsing: {dataElement}");
82 string[] dataParts = dataElement.Split(
'=', 2);
84 if (dataParts.Length <= 1)
86 Debug.Log($
"No named argument.");
90 Debug.Log($
"Found argument {dataParts[0]} - {dataParts[1]}");
91 parameters.Add(dataParts[0], dataParts[1]);