Repository navigation
fix(metascraper-author): make strict guard await its rule - #888
Conversation
`strict` called async `toRule` rules synchronously, so the two-word regex tested "[object Promise]" and never rejected anything. Await the rule and return `undefined` on rejection: `findRule` treats `false` as a found value (`has(false)` is true), which would end the rule chain. Closes #887 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [metascraper](https://metascraper.js.org) ([source](https://github.com/microlinkhq/metascraper)) | [`5.58.4` → `5.58.5`](https://renovatebot.com/diffs/npm/metascraper/5.58.4/5.58.5) |  |  | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/99) for more information. --- ### Release Notes <details> <summary>microlinkhq/metascraper (metascraper)</summary> ### [`v5.58.5`](https://github.com/microlinkhq/metascraper/blob/HEAD/CHANGELOG.md#5585-2026-10-15) [Compare Source](microlinkhq/metascraper@v5.58.4...v5.58.5) ##### Bug Fixes - **metascraper-author:** make strict guard await its rule ([#​888](microlinkhq/metascraper#888)) ([c1188fc](microlinkhq/metascraper@c1188fc)), closes [#​887](microlinkhq/metascraper#887) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - "before 9am on tuesday" - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNjcuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE2Ny4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==--> Reviewed-on: https://code.futo.org/harbor/harbor/pulls/1931
Closes #887.
Problem
strictinpackages/metascraper-author/src/index.jswraps rules built bytoRule, which are async. It called them withoutawait, soREGEX_STRICT.test(value)was testing"[object Promise]". That string has two words, so the test always passed and the guard never rejected anything. Single-word matches from the five class/path heuristics (for example<span class="author">Newsvilla</span>) came through as the author.Fix
On rejection the guard returns
undefined, notfalse, which is where this differs from the fix suggested in the issue.findRulestops at the first value that passeshas(), andhas(false)istrue. Returningfalsewould therefore end the rule chain at the first strict rule that doesn't match, andauthorwould come out asfalseon most pages. With that variant, this package's existingtwitter:creatortest fails.Behavior change
packages/metascraperchange, and both results improve:lsariasfstandard.combecomesLauren Saria.HackerYoubecomeswesbos.itemprop,rel="author",screennameandtwitter:creator. None of those rules has the two-word check.Tests
packages/metascraper-author: added 3 tests: a single word is rejected, two words are kept, and a strict rule that doesn't match falls through to the next rule. The new tests run against metascraper-author alone, becausemetascraper-readabilityfinds bylines independently.&& valuevariant: 4 tests fail (the 3 new ones plus thetwitter:creatortest).packages/metascraper(TZ=UTC npx ava): 120 passed after updating the two snapshots above.🤖 Generated with Claude Code
Note
Low Risk
Narrow fix to author heuristic filtering in metascraper-author with added tests; no auth, security, or data-handling changes.
Overview
Fixes a bug where the
strictauthor guard never ran its two-word check because it called async rules withoutawait, soREGEX_STRICTwas applied to a Promise string and always passed.strictis nowasync,awaits the wrapped rule, and returnsundefined(notfalse) when the value fails the regex sofindRulecan fall through to later rules such astwitter:creator.Behavior: single-word hits from class/path/byline heuristics are dropped; multi-word names are kept. Integration snapshots improve author extraction on learnnode and sfstandard. Three unit tests cover rejection, acceptance, and fall-through.
Reviewed by Cursor Bugbot for commit aa4d50a. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit