Skip to content

OS and version parsing #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ Docs/publishing-release.md.meta
/Scripts/Editor/Help/
/Scripts/Editor/Help.meta
*/MRefBuilder.config.meta
package-lock.json
package-lock.json.meta
15 changes: 11 additions & 4 deletions Scripts/Connection/RESTConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
using System.Text.RegularExpressions;

#if !NETFX_CORE
using System.Net;
Expand Down Expand Up @@ -376,14 +377,20 @@ private void AddHeaders(Dictionary<string, string> headers)
}

string osInfo = SystemInfo.operatingSystem;
int osIndex = osInfo.IndexOf(" ");
string os = osInfo.Substring(0, osIndex).Replace(" ", "");
string osVersion = osInfo.Substring(osIndex).Replace(" ", "");
Regex pattern = new Regex("\\d+(\\.\\d+)+");
Match m = pattern.Match(osInfo);
string osVersion = m.Value;
string os = osInfo.Replace(osVersion, "").Replace(" ", "");
if(os.Contains("()"))
{
os = os.Replace("()", "-");
}

headers.Add("User-Agent",
string.Format(
"{0} {1} {2} {3}",
Constants.String.Version,
os,
os,
osVersion,
Application.unityVersion
));
Expand Down
3 changes: 3 additions & 0 deletions Scripts/Utilities/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,9 @@ public static string CreateAuthorization(string username, string password)
#region Has Bad First Character
public static bool HasBadFirstOrLastCharacter(string value)
{
if (string.IsNullOrEmpty(value))
return false;

return value.StartsWith("{") || value.StartsWith("\"") || value.EndsWith("}") || value.EndsWith("\"");
}
#endregion
Expand Down
Loading