Repository navigation
Conversation
checkPreviewField called new URL(v) on values safeImageUrl had already rejected as unparseable, so a typo like https://[bad aborted the whole validate run with a stack trace instead of reporting the field error. Parse defensively and report the normal public-host error.
TMHSDigital
added a commit
that referenced
this pull request
Nov 6, 2026
The fixes these pull requests made had already landed on main, so their branches conflict; these are the parts main did not have: - data.schema.json: list items must be non-empty strings (minLength 1), from #244. schema-check.mjs gains minLength (by character) so the build's own schema check can enforce it. - checks.test.mjs: a preview URL with an unclosed IPv6 bracket, and one carrying credentials, are refused rather than thrown, from #243. - site/README.md: a paragraph on opensearch.xml, from #242. Co-authored-by: harshkanhat <kanhatharsh@gmail.com> Co-authored-by: bfs2021 <101915083+bfs2021@users.noreply.github.com> Co-authored-by: Ritesh Yadav <riteshyadav33302111@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LpkeXQPaUhxjgqdqnk6BrJ
Owner
|
Thank you! #233 was fixed on Your two extra test cases, the unclosed IPv6 bracket and a URL carrying credentials, weren't covered on |
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.
Problem
npm run validatecrashes with a stack trace when an entry'spreview:looks like an https URL but cannot be parsed (for examplepreview: https://[bad), instead of reporting a validation error. Fixes #233.Root cause
checkPreviewFieldevaluatedsafeImageUrl(v) === new URL(v).hrefon one line. For an unparseable URLsafeImageUrlreturnsnull, but the second operand still callsnew URL(v), which throwsERR_INVALID_URLand aborts the whole validate run before any other check can report.Fix
Parse
vdefensively once (try/catch aroundnew URL) and only compare againstsafeImageUrl(v)when the URL actually parsed. An unparseable URL now falls through to the normalpreview must be an https:// image URL on a public hosterror, and behaviour for every parseable value is unchanged (same comparison as before).Testing
site/checks.test.mjs: unparseable https URL (https://[bad) and URL with userinfo — both rejected with the public-host message. Before the fix the unparseable case crashed the suite (TypeError: Invalid URLatchecks.mjs:1066); after it the suite is green: 242 assertions across 34 checks.node site/lib/lib.test.mjs: 986 assertions OK.npm run validateover the real catalog completes without a crash.PR drafted with an agent; the diff and tests above were verified locally.