Image sets: a suffix that ends the number before is a repeat too
Test and deploy / test (push) Successful in 48s
Test and deploy / edge (push) Successful in 1m53s
Test and deploy / deploy (push) Successful in 1m24s

"051 - White leather kate054001_1_1.jpg": the index is inside 054001
(set 054, image 001) and _1_1 repeats it, but only a suffix equal to the
whole number before counted as a repeat, so the set kept 054001 and every
image was a release (Duke's threads: 2,791 releases of 3,251 files). A
suffix that the number before ends with is a repeat as well. Both
implementations; tests; fixtures identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-12 02:45:29 +02:00
1 parent 392ff09910
commit f094fb4593
3 files changed
+7 -2

No files matched your search

+3 -1
View File
@@ -156,7 +156,9 @@ export function imageSet(stem: string): string {
const previous = /(\d+)\D*$/.exec(before)
if (!previous) break
const n = m[1]
if (Number(n) === Number(previous[1]) || /^(?:19|20)\d\d$/.test(n) || n.length >= 4) s = before
// A repeat: the same number, or the end of the one before ("kate054001_1_1": 054001 ends in 1).
const repeat = Number(n) === Number(previous[1]) || previous[1].endsWith(n)
if (repeat || /^(?:19|20)\d\d$/.test(n) || n.length >= 4) s = before
else break
}
return /\d/.test(s) ? s.replace(/\d+\D*$/, '') : ''