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
// 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.
// lightnovelworld is unscoped for a stronger reason: its chapter addresses
// 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.
// lightnovelworld is unscoped and body-truncated instead — see lnwChapterRe.
func latestChapterFrom(site, seriesURL, body string) (latestChapter, bool) {
var re *regexp.Regexp
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
// lnwChapterRe). A body without the marker is skipped, never scanned
// whole — a redesign must degrade into staleness, not into a wrong
// shared value. The body length distinguishes a genuine markup change
// from a body the size cap cut short.
// shared value; the logged body length tells a markup change from a
// body the size cap cut short.
i := strings.Index(body, lnwCommentMarker)
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
}
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
// Chapter Slug; the 100-423 block under the other slug must still win.
// The body is the chapter-list portion of lnwSeriesFixture with the
// comment block omitted (that is the next case's job); the marker is
// kept, because a body without it is skipped, not scanned.
// comment block omitted; the marker is kept, because a body without it
// is skipped, not scanned.
{
name: "lightnovelworld max spans both chapter slugs",
site: "lightnovelworld",