Conversation
|
| * scripts. Decode every payload into one searchable text blob. | ||
| */ | ||
| function extractFlightText(html: string): string { | ||
| const re = /self\.__next_f\.push\(\[1,"([\s\S]*?)"\]\)<\/script>/g; |
There was a problem hiding this comment.
| function parseChapterPage(flight: string): string | null { | ||
| if (/"locked":true/.test(flight)) return LOCKED_MESSAGE; | ||
| const m = /"body":\["([\s\S]*?)"\],"translatorNotes"/.exec(flight); | ||
| if (!m) return null; |
There was a problem hiding this comment.
Please add captured-payload tests for search and chapter parsing. The live checker accepts an empty search result and reads only the first chapter, so it cannot catch changes that make the query marker, locked-chapter check, or body extraction show unrelated results or unreadable chapters.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Add captured-payload tests for the Nightjar Reads plugin to ensure proper functionality and regression coverage.
|
Added captured-payload tests covering the remaining review item —
Fixtures are minimized captured flight chunks (~20 KB total), so the tests need no live network. esbuild (already a devDependency) bundles the plugin at test time with |
|
Could we remove the tests? I'll configure PR reviews to not ask for tests until a proper test framework is added. |
|
Done — removed the tests (the whole plugins/english/tests directory). Happy to drop them entirely given there's no test framework set up yet. |
|
Updated the plugin with a hardening pass from a full code audit: search results are now bounded to the result section and the page's own result count (quoted queries work), the locked-chapter check is scoped to the chapter's own record instead of the whole page, chapter parsing tolerates fractional chapter numbers and non-string body entries, and page responses are size-capped. Normal content parses identically to before. |
Adds a source plugin for Nightjar Reads (https://nightjarreads.com), an English novel site running on Next.js. The site embeds its data in Next.js React Flight payloads, which the plugin decodes and parses.
Features:
Verification:
npm run check:plugin -- plugins/english/nightjarreads.tspasses all 4 checks (popularNovels, searchNovels, parseNovel, parseChapter)