Browse Source

Fix Beat Saber version parsing

pull/100/head
Meivyn 5 months ago
parent
commit
3ccb5df346
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      IPA.Loader/Utilities/AlmostVersion.cs

+ 8
- 2
IPA.Loader/Utilities/AlmostVersion.cs View File

@ -10,7 +10,7 @@ using Version = Hive.Versioning.Version;
namespace IPA.Utilities
{
/// <summary>
/// A type that wraps <see cref="Version"/> so that the string of the version is stored when the string is
/// A type that wraps <see cref="Version"/> so that the string of the version is stored when the string is
/// not a valid <see cref="Version"/>.
/// </summary>
public class AlmostVersion : IComparable<AlmostVersion>, IComparable<Version>,
@ -61,7 +61,7 @@ namespace IPA.Utilities
public AlmostVersion(SVersion ver) : this(ver?.UnderlyingVersion ?? throw new ArgumentNullException(nameof(ver))) { }
/// <summary>
/// Creates an <see cref="AlmostVersion"/> from the version string in <paramref name="vertext"/> stored using
/// Creates an <see cref="AlmostVersion"/> from the version string in <paramref name="vertext"/> stored using
/// the storage mode specified in <paramref name="mode"/>.
/// </summary>
/// <param name="vertext">the text to parse as an <see cref="AlmostVersion"/></param>
@ -92,7 +92,13 @@ namespace IPA.Utilities
if (mode == StoredAs.SemVer)
{
StorageMode = StoredAs.SemVer;
#if BeatSaber
var index = str.IndexOf('_');
var versionString = index >= 0 ? str.Substring(0, index) : str;
var result = Version.TryParse(versionString, out var version);
#else
var result = Version.TryParse(str, out var version);
#endif
SemverValue = version;
return result;
}


Loading…
Cancel
Save