fix: hero[_\-a-z] partial selector strips article hero images and captions#289
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
…tions The hero removal selector was a partial match on class/id substrings, so it stripped <figure class='hero-image'> and similar legitimate article-hero elements alongside the page-header hero blocks it was meant to target. Tightened the regex to anchor on standalone class boundaries and added test fixtures covering both the false-positive case and the original target. Fixes kepano#279
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.
Summary
The hero-removal selector in
src/removals/selectors.tswas a partial substring match. Any element whose class contained "hero" (e.g.,<figure class="hero-image">) was getting removed, not just page-header hero blocks. Tightened the regex to anchor on standalone class boundaries.Why this matters
Reporter pointed at the exact partial selector. Article hero images and captions were silently being stripped from the extracted content, causing the article body to start at "paragraph 2" with the visual lead removed.
Changes
src/removals/selectors.ts- rewrite the hero match to require a word boundary on either side, sohero-imageandarticle-hero-captiondon't match the page-header hero selector. Add tests for both the false-positive case and the original target case.Testing
pnpm test src/removals/selectors.test.ts.Fixes #279