fix some null reference exceptions

This commit is contained in:
2025-04-23 15:40:01 +02:00
parent df21d8180d
commit a5eb9fad43

View File

@@ -44,27 +44,27 @@ public static class Extensions
public static string GetSourceUrl(this InstallAction @this, Version version, string? overwriteVersion = null) public static string GetSourceUrl(this InstallAction @this, Version version, string? overwriteVersion = null)
{ {
if (!string.IsNullOrWhiteSpace(overwriteVersion)) if (!string.IsNullOrWhiteSpace(overwriteVersion))
return @this.SourceUrl.Replace("{version}", overwriteVersion); return @this.SourceUrl?.Replace("{version}", overwriteVersion);
if (version is not null) if (version is not null)
return @this.SourceUrl.Replace("{version}", version.ToString(3)); return @this.SourceUrl?.Replace("{version}", version.ToString(3));
return @this.SourceUrl; return @this.SourceUrl;
} }
public static string GetInstallUrl(this ModpackConfig @this, string? overwriteRefTag = null) public static string GetInstallUrl(this ModpackConfig @this, string? overwriteRefTag = null)
{ {
if (!string.IsNullOrWhiteSpace(overwriteRefTag)) if (!string.IsNullOrWhiteSpace(overwriteRefTag))
return @this.InstallUrl.Replace("{ref}", overwriteRefTag); return @this.InstallUrl?.Replace("{ref}", overwriteRefTag);
if (!string.IsNullOrWhiteSpace(@this.RefTag)) if (!string.IsNullOrWhiteSpace(@this.RefTag))
return @this.InstallUrl.Replace("{ref}", @this.RefTag); return @this.InstallUrl?.Replace("{ref}", @this.RefTag);
return @this.InstallUrl; return @this.InstallUrl;
} }
public static string GetUpdateUrl(this ModpackConfig @this, string? overwriteRefTag = null) public static string GetUpdateUrl(this ModpackConfig @this, string? overwriteRefTag = null)
{ {
if (!string.IsNullOrWhiteSpace(overwriteRefTag)) if (!string.IsNullOrWhiteSpace(overwriteRefTag))
return @this.UpdateUrl.Replace("{ref}", overwriteRefTag); return @this.UpdateUrl?.Replace("{ref}", overwriteRefTag);
if (!string.IsNullOrWhiteSpace(@this.RefTag)) if (!string.IsNullOrWhiteSpace(@this.RefTag))
return @this.UpdateUrl.Replace("{ref}", @this.RefTag); return @this.UpdateUrl?.Replace("{ref}", @this.RefTag);
return @this.UpdateUrl; return @this.UpdateUrl;
} }
} }