Refactor episode regex handling for improved clarity and maintainability
ci / build-backend (push) Successful in 2m1s
ci / build-frontend (push) Successful in 52s
ci / tests (push) Successful in 2m16s
ci / sonar (push) Successful in 4m44s

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.
This commit is contained in:
Leonid Pershin
2026-07-27 02:28:29 +03:00
parent 2045b1a3f2
commit 07c43a6875
@@ -56,7 +56,8 @@ export function buildEpisodeRegex(fileName: string, occurrenceIndex: number): st
// к первому сезону, и на «S02E05» оно бы уже не сработало. // к первому сезону, и на «S02E05» оно бы уже не сработало.
const anchor = trailingRun(anchorSource, isLetter) 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)»). // Слова перед числом нет — цепляемся за последний разделитель («- 05», «(05)»).
const punctuation = gap.trim().slice(-1) const punctuation = gap.trim().slice(-1)