From 07c43a6875097e3b218e10ec11f0a9f2f94e45d2 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Mon, 27 Jul 2026 02:28:29 +0300 Subject: [PATCH] Refactor episode regex handling for improved clarity and maintainability Updated the separator handling in the buildEpisodeRegex function to enhance readability. The change replaces the inline conditional for the gap with a dedicated variable, making the code more understandable while maintaining functionality. --- frontend/src/features/admin/media/episode-regex.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/features/admin/media/episode-regex.ts b/frontend/src/features/admin/media/episode-regex.ts index 024cdde..a807e13 100644 --- a/frontend/src/features/admin/media/episode-regex.ts +++ b/frontend/src/features/admin/media/episode-regex.ts @@ -56,7 +56,8 @@ export function buildEpisodeRegex(fileName: string, occurrenceIndex: number): st // к первому сезону, и на «S02E05» оно бы уже не сработало. const anchor = trailingRun(anchorSource, isLetter) - if (anchor) return `${escapeRegex(anchor)}${gap ? String.raw`[\s._-]*` : ''}${digits}` + const separator = gap ? String.raw`[\s._-]*` : '' + if (anchor) return `${escapeRegex(anchor)}${separator}${digits}` // Слова перед числом нет — цепляемся за последний разделитель («- 05», «(05)»). const punctuation = gap.trim().slice(-1)