Skip to content

fix(showcase): skip non-absolute hrefs instead of crashing - #1682

Merged
julien-deramond merged 1 commit into
mainfrom
fix/showcase-invalid-url-href
Sep 14, 2026
Merged

julien-deramond merged 1 commit into
mainfrom
fix/showcase-invalid-url-href

Conversation

@julien-deramond

Copy link
Copy Markdown
Member

Summary

The Update Showcase Sites workflow crashed with:

TypeError: Invalid URL
    at scripts/libs/showcaseScrapper.ts:278:23
    input: '#'

#filterHrefs calls new URL(href) on every link extracted from a discussion comment's HTML. Link extraction uses linkedom's parseHTML(), whose anchor .href getter returns the raw href attribute 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.

  • Wrap the new URL(href) call in #filterHrefs in try/catch so invalid/non-absolute hrefs are filtered out instead of throwing.
  • Add a regression test covering a comment with a bare # 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 in node_modules)

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>
@vercel

vercel Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openresource-dev Ready Ready Preview Sep 14, 2026 6:19pm UTC

@julien-deramond
julien-deramond merged commit a62a222 into main Sep 14, 2026
4 checks passed
@julien-deramond
julien-deramond deleted the fix/showcase-invalid-url-href branch September 14, 2026 18:19

This branch was successfully deployed

1 active deployment
Preview — bd5994c4 Deployed Sep 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant