Skip to content

Commit c36a253

Browse files
committed
IconId not being properly calculated (fix #3752)
1 parent 5099085 commit c36a253

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

  • src/UniGetUI.PackageEngine.PackageManagerClasses/Packages

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Package.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,7 @@ public Package(
9898

9999
ignoredId = IgnoredUpdatesDatabase.GetIgnoredIdForPackage(this);
100100

101-
_iconId = Manager.Name switch
102-
{
103-
"Winget" => Source.Name switch
104-
{
105-
"Steam" => id.ToLower().Split("\\")[^1].Replace("steam app ", "steam-").Trim(),
106-
"Local PC" => id.ToLower().Split("\\")[^1],
107-
"Microsoft Store" => id.IndexOf('_') < id.IndexOf('.') ? // If the first underscore is before the period, this ID has no publisher
108-
string.Join('_', id.ToLower().Split("\\")[1].Split("_")[0..^4]) : // no publisher: remove `MSIX\`, then the standard ending _version_arch__{random id}
109-
string.Join('_', string.Join('.', id.ToLower().Split(".")[1..]).Split("_")[0..^4]), // remove the publisher (before the first .), then the standard _version_arch__{random id}
110-
_ => string.Join('.', id.ToLower().Split(".")[1..]),
111-
},
112-
"Scoop" => id.ToLower().Replace(".app", ""),
113-
"Chocolatey" => id.ToLower().Replace(".install", "").Replace(".portable", ""),
114-
"vcpkg" => id.ToLower().Split(":")[0].Split("[")[0],
115-
_ => id.ToLower()
116-
};
101+
_iconId = GenerateIconId(this);
117102
}
118103

119104
/// <summary>
@@ -334,6 +319,31 @@ public static void ResetIconCache()
334319
{
335320
_cachedIconPaths.Clear();
336321
}
322+
323+
private static string GenerateIconId(Package p)
324+
{
325+
return (p.Manager.Name switch
326+
{
327+
"Winget" => p.Source.Name switch
328+
{
329+
"Steam" => p.Id.ToLower().Split("\\")[^1].Replace("steam app ", "steam-").Trim(),
330+
"Local PC" => p.Id.Split("\\")[^1],
331+
"Microsoft Store" => p.Id.IndexOf('_') < p.Id.IndexOf('.')
332+
? // If the first underscore is before the period, this ID has no publisher
333+
string.Join('_', p.Id.Split("\\")[1].Split("_")[0..^4])
334+
: // no publisher: remove `MSIX\`, then the standard ending _version_arch__{random p.Id}
335+
string.Join('_',
336+
string.Join('.', p.Id.Split(".")[1..])
337+
.Split("_")
338+
[0..^4]), // remove the publisher (before the first .), then the standard _version_arch__{random p.Id}
339+
_ => string.Join('.', p.Id.Split(".")[1..]),
340+
},
341+
"Scoop" => p.Id.Replace(".app", ""),
342+
"Chocolatey" => p.Id.Replace(".install", "").Replace(".portable", ""),
343+
"vcpkg" => p.Id.Split(":")[0].Split("[")[0],
344+
_ => p.Id
345+
}).ToLower().Replace('_', '-').Replace('.', '-').Replace(' ', '-').Replace('/', '-').Replace(',', '-');
346+
}
337347
}
338348
}
339349

0 commit comments

Comments
 (0)