fix: decode HTML entities in scraped trending descriptions - #39
Draft
DamengRandom wants to merge 2 commits into
Draft
fix: decode HTML entities in scraped trending descriptions#39DamengRandom wants to merge 2 commits into
DamengRandom wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013v6SNv4axPxsCPcmEFNk86
Keeps the replace callback's CRAP score under Fallow's threshold and covers the out-of-range code point guard. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013v6SNv4axPxsCPcmEFNk86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #38
parseTrendingHtmlstripped tags out of the scraped<p>but left HTML entities encoded, so a repo description GitHub renders asOctadesk & Intercomwas stored and prompted asOctadesk & Intercom. Three of the 32 repos on today's trending page were affected.Change
src/tools/trending-scrape.tool.ts— decode entities after the tags come out, so the tag-strip is not re-applied to a decoded<Suspense>. Named entities GitHub emits (&<>"' ) plus decimal and hex numeric references; anything unrecognised is left exactly as it was, soAT&Tand¬anentity;survive intact.parseTrendingHtmlis now exported so the parser can be tested directly, matching howfitRepos,toAiNewsItemsandmergeSummariesare already exposed for their tests.Test
src/tools/trending-scrape.test.ts— new, built on an article block trimmed from a realgithub.com/trending/typescript?since=dailyresponse. Three of the five tests fail without the fix:The other two pass either way on purpose — they guard against the fix over-reaching or disturbing the rest of the parse.
With the fix, the full suite, the type-check and the format check all pass:
Observed vs reasoned
pnpm test/pnpm tsc/pnpm format:checkafter the fix..envin this environment, so no database was written to —saveTrendingRepospassesrepo.descriptionthrough as a bind parameter with no transformation, which is where the claim comes from.Generated by Claude Code