Skip to content

Commit

Permalink
fix: Change to REGEX matching for update check
Browse files Browse the repository at this point in the history
  • Loading branch information
SarenDev committed Jun 11, 2021
1 parent 48921c8 commit 457efe0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Assets/Scripts/HomegrownScripts/UpdateCheck.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System.Text.RegularExpressions;
using UnityEngine.Networking;
using UnityEngine;

Expand All @@ -20,20 +21,18 @@ IEnumerator getUpdate(){

string currentVersion = Application.version.TrimEnd('A');
string webVersion = findRelease(net.downloadHandler.text);
string webVtrimmed = webVersion.TrimEnd('A');

if (!webVtrimmed.Equals(currentVersion) && !currentVersion.Equals("")){
setNotifier(webVersion);
if (!webVersion.Equals(currentVersion) && !currentVersion.Equals("")){
setNotifier(webVersion+'A');
}
}

private string findRelease(string src){
if (src.Contains("v") && src.Contains("\"")){
int Start = src.IndexOf("v", 0) + 1;
int End = src.IndexOf("\"", Start);
return src.Substring(Start, End - Start);
}
return "";
private string findRelease(string input)
{
Regex regex1 = new Regex("\"tag_name\": \"(?:[^\"]|\"\")*\",", RegexOptions.IgnoreCase);
Regex regex2 = new Regex("([0-9]+(\\.[0-9]+)+)", RegexOptions.IgnoreCase);
Match matchPre = regex1.Match(input);
Match matchFin = regex2.Match(matchPre.ToString());
return matchFin.Captures[0].ToString();
}

private void setNotifier(string webVersion){
Expand Down

0 comments on commit 457efe0

Please sign in to comment.