From 457efe0b89defa2fa10df1a9ed30dbe9d8673304 Mon Sep 17 00:00:00 2001 From: SarenDev <54124554+SarenDev@users.noreply.github.com> Date: Fri, 11 Jun 2021 22:51:48 +0200 Subject: [PATCH] fix: Change to REGEX matching for update check --- .../Scripts/HomegrownScripts/UpdateCheck.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/HomegrownScripts/UpdateCheck.cs b/Assets/Scripts/HomegrownScripts/UpdateCheck.cs index a4d6820..7bee5f4 100644 --- a/Assets/Scripts/HomegrownScripts/UpdateCheck.cs +++ b/Assets/Scripts/HomegrownScripts/UpdateCheck.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Text.RegularExpressions; using UnityEngine.Networking; using UnityEngine; @@ -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){