Skip to content

Commit 457efe0

Browse files
committed
fix: Change to REGEX matching for update check
1 parent 48921c8 commit 457efe0

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Assets/Scripts/HomegrownScripts/UpdateCheck.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections;
2+
using System.Text.RegularExpressions;
23
using UnityEngine.Networking;
34
using UnityEngine;
45

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

2122
string currentVersion = Application.version.TrimEnd('A');
2223
string webVersion = findRelease(net.downloadHandler.text);
23-
string webVtrimmed = webVersion.TrimEnd('A');
24-
25-
if (!webVtrimmed.Equals(currentVersion) && !currentVersion.Equals("")){
26-
setNotifier(webVersion);
24+
if (!webVersion.Equals(currentVersion) && !currentVersion.Equals("")){
25+
setNotifier(webVersion+'A');
2726
}
2827
}
2928

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

3938
private void setNotifier(string webVersion){

0 commit comments

Comments
 (0)