From c629fa7c0be7546f6668950668204990bbbb6cab Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 22 May 2017 21:33:59 +0800 Subject: [PATCH] Fix test case --- source/net/filebot/media/ReleaseInfo.java | 16 ++++++++++------ test/net/filebot/media/ReleaseInfoTest.java | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index 1b9d5879..8362ee84 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -100,15 +100,19 @@ public class ReleaseInfo { // check file and folder for release group names String[] groups = releaseGroup.get(); - // try case-sensitive match - String match = matchLast(getReleaseGroupPattern(true), groups, name); + for (boolean strict : new boolean[] { true, false }) { + String match = matchLast(getReleaseGroupPattern(strict), groups, name); - if (match != null) { - return match; + if (match != null) { + // group pattern does not match closing brackets in GROUP[INDEX] patterns + if (match.lastIndexOf(']') < match.lastIndexOf('[')) { + return match + ']'; + } + return match; + } } - // try case-insensitive match - return matchLast(getReleaseGroupPattern(false), groups, name); + return null; } private Pattern languageTag; diff --git a/test/net/filebot/media/ReleaseInfoTest.java b/test/net/filebot/media/ReleaseInfoTest.java index f276dbba..f4939fa4 100644 --- a/test/net/filebot/media/ReleaseInfoTest.java +++ b/test/net/filebot/media/ReleaseInfoTest.java @@ -20,6 +20,8 @@ public class ReleaseInfoTest { @Test public void getReleaseGroup() throws Exception { assertEquals("aXXo", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-aXXo")); + assertEquals("aXXo", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-[aXXo]")); + assertEquals("aXXo[RARBG]", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-aXXo[RARBG]")); } @Test