aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorShadowghost <Shadowghost@users.noreply.github.com>2026-09-15 11:16:00 -0400
committerCody Robibero <cody@robibe.ro>2026-09-15 11:16:00 -0400
commit87a57a4f923cecbb9c3cee5879e444a9b409392a (patch)
tree0b65b34d27e93c3920a33983252fd9d1117dc106 /tests
parent20a9513edb58475401fb56a512b8b5ce2149af07 (diff)
Backport pull request #17931 from jellyfin/release-12.z
Fix decimal point handling in version names Original-merge: ad1bf20e8424fa6433409a57f6f055ec7c394910 Merged-by: crobibero <cody@robibe.ro> Backported-by: Cody Robibero <cody@robibe.ro>
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs b/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs
index f9b29e576b..f363968909 100644
--- a/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs
+++ b/tests/Jellyfin.Controller.Tests/Entities/BaseItemTests.cs
@@ -203,6 +203,17 @@ public class BaseItemTests
"Blade Runner (1982) [EE by ADM] [480p HEVC AAC]",
"[Final Cut] [1080p HEVC AAC]",
"[EE by ADM] [480p HEVC AAC]")]
+ // Numeric version labels: the dot between the digits is a decimal point, not a delimiter, so the
+ // prefix retreats past it to the '-' instead of leaving "0" / "11".
+ [InlineData(
+ "Evangelion 1.0 You Are (Not) Alone (2007) - 1.0",
+ "Evangelion 1.0 You Are (Not) Alone (2007) - 1.11",
+ "1.0",
+ "1.11")]
+ // Numeric labels with no structural delimiter at all fall back to the space boundary.
+ [InlineData("Movie (2007) 1.0", "Movie (2007) 1.11", "1.0", "1.11")]
+ // A dot followed by a non-digit is still a delimiter, even after a digit.
+ [InlineData("Movie - Part 1.HDR", "Movie - Part 1.SDR", "HDR", "SDR")]
public void GetMediaSourceName_CommonPrefix_Valid(string primaryName, string altName, string expectedPrimary, string expectedAlt)
{
var primaryPath = "/Shows/Demo/Season 01/" + primaryName + ".mkv";
@@ -234,6 +245,24 @@ public class BaseItemTests
}
[Fact]
+ public void GetCommonVersionPrefix_NumericLabels_KeepsWholeNumber()
+ {
+ // Three versions labelled "1.0", "1.01" and "1.11": the common prefix stops inside the version
+ // number, so it must retreat past the decimal point to the '-' delimiter.
+ string[] fileNames =
+ [
+ "Evangelion 1.0 You Are (Not) Alone (2007) - 1.0",
+ "Evangelion 1.0 You Are (Not) Alone (2007) - 1.01",
+ "Evangelion 1.0 You Are (Not) Alone (2007) - 1.11"
+ ];
+
+ var prefix = BaseItem.GetCommonVersionPrefix(fileNames);
+
+ Assert.Equal("Evangelion 1.0 You Are (Not) Alone (2007) -", prefix);
+ Assert.Equal(["1.0", "1.01", "1.11"], fileNames.Select(n => n[prefix.Length..].TrimStart(' ')));
+ }
+
+ [Fact]
public void GetAlternateVersion_ReturnsMatchingLocalVersion()
{
var (primary, alt1, alt2) = SetupVersionGroup();