Tighten lnw comments and log form after review (#87)

Cross-reference lnwChapterRe from the function doc instead of restating
its rationale, drop the redundant '; skipping' from the fail-closed log
to match the package's bare verb:detail form, and reword the truncation
comment so the logged body length is not described as a code-made
distinction.
This commit is contained in:
2026-08-11 13:02:18 +07:00
parent ecce453d13
commit 51b0094430
2 changed files with 6 additions and 10 deletions
+4 -8
View File
@@ -98,11 +98,7 @@ const lnwCommentMarker = "wpd-threads"
// such guarantee — demonicChapterRe matches any chaptered.php?manga=<id> anchor // such guarantee — demonicChapterRe matches any chaptered.php?manga=<id> anchor
// with no per-series scoping, because the stored series_id for demonic is a // with no per-series scoping, because the stored series_id for demonic is a
// slug, not the numeric id the URL carries, so it cannot easily be scoped. // slug, not the numeric id the URL carries, so it cannot easily be scoped.
// lightnovelworld is unscoped for a stronger reason: its chapter addresses // lightnovelworld is unscoped and body-truncated instead — see lnwChapterRe.
// carry the Chapter Slug, which is not the Series identity, so no stored-slug
// pattern can cover a Series' whole list (see lnwChapterRe). Instead of
// scoping, its branch scans only the body before the comment thread marker and
// skips the page when the marker is absent.
func latestChapterFrom(site, seriesURL, body string) (latestChapter, bool) { func latestChapterFrom(site, seriesURL, body string) (latestChapter, bool) {
var re *regexp.Regexp var re *regexp.Regexp
switch site { switch site {
@@ -151,11 +147,11 @@ func latestChapterFrom(site, seriesURL, body string) (latestChapter, bool) {
// page any visitor can write to, so the scan never reads past it (see // page any visitor can write to, so the scan never reads past it (see
// lnwChapterRe). A body without the marker is skipped, never scanned // lnwChapterRe). A body without the marker is skipped, never scanned
// whole — a redesign must degrade into staleness, not into a wrong // whole — a redesign must degrade into staleness, not into a wrong
// shared value. The body length distinguishes a genuine markup change // shared value; the logged body length tells a markup change from a
// from a body the size cap cut short. // body the size cap cut short.
i := strings.Index(body, lnwCommentMarker) i := strings.Index(body, lnwCommentMarker)
if i < 0 { if i < 0 {
log.Printf("latest poll %q: no %s marker in %d bytes; skipping", seriesURL, lnwCommentMarker, len(body)) log.Printf("latest poll %q: no %s marker in %d bytes", seriesURL, lnwCommentMarker, len(body))
return latestChapter{}, false return latestChapter{}, false
} }
body = body[:i] body = body[:i]
+2 -2
View File
@@ -414,8 +414,8 @@ func TestLatestChapterFrom(t *testing.T) {
// Stored before the slug split, so the address carries the ...-not // Stored before the slug split, so the address carries the ...-not
// Chapter Slug; the 100-423 block under the other slug must still win. // Chapter Slug; the 100-423 block under the other slug must still win.
// The body is the chapter-list portion of lnwSeriesFixture with the // The body is the chapter-list portion of lnwSeriesFixture with the
// comment block omitted (that is the next case's job); the marker is // comment block omitted; the marker is kept, because a body without it
// kept, because a body without it is skipped, not scanned. // is skipped, not scanned.
{ {
name: "lightnovelworld max spans both chapter slugs", name: "lightnovelworld max spans both chapter slugs",
site: "lightnovelworld", site: "lightnovelworld",