fix(showcase): skip non-absolute hrefs instead of crashing - #1682
Merged
Merged
Conversation
linkedom's anchor `.href` getter returns the raw attribute value unresolved, so an in-page anchor link like `<a href="#">` in a discussion comment produced the literal string "#". Passing that to `new URL()` threw uncaught, crashing the whole update:showcase script. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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 Update Showcase Sites workflow crashed with:
#filterHrefscallsnew URL(href)on every link extracted from a discussion comment's HTML. Link extraction useslinkedom'sparseHTML(), whose anchor.hrefgetter returns the rawhrefattribute unresolved (no base-URL resolution). So a comment containing a plain in-page anchor link like<a href="#">produced the literal string"#", which isn't a valid absolute URL —new URL("#")threw uncaught and crashed the whole script.new URL(href)call in#filterHrefsin try/catch so invalid/non-absolute hrefs are filtered out instead of throwing.#link.Test plan
npx vitest run tests/showcase.test.ts— 17/17 pass (added a new test: "should skip non-absolute hrefs without throwing")npx tsc --noEmit— no new errors (pre-existing unrelated errors innode_modules)