feat(w3c/headers): validate header links#5143
Open
marcoscaceres wants to merge 4 commits intomainfrom
Open
Conversation
bb1051e to
5982fb1
Compare
- Warn if latestVersion URL doesn't resolve (non-FPWD docs) - CG drafts (specStatus ending in -DRAFT) no longer require latestVersion - Extract resourceExists() helper that returns the final URL after redirects (or null), replacing ad-hoc fetch+ok patterns - deriveHistoryURI() now returns a value instead of mutating conf, and uses resourceExists() to avoid duplicating fetch logic - Guard conf.historyURI = null (user suppression) at the call site so explicit null is not overwritten by derivation - Fix URL construction: use response.url (post-redirect) for the history URL rather than the pre-redirect constructed URL Fixes #4037 (rebased from validate_latest branch)
5982fb1 to
721ec7b
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances W3C header handling by adding validation/verification around key header links (notably latestVersion and historyURI) and extends the test suite to cover the new behaviors, aiming to surface broken header links earlier via warnings/errors.
Changes:
- Add a HEAD check for derived
latestVersionURLs and emit aw3c/headerswarning when the URL can’t be reached. - Adjust
historyURIderivation to support explicit suppression (null) and refactor URL probing intoresourceExists(). - Update/extend
w3c/headerstests (warnings filter, status loops, new warning expectation).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
tests/spec/w3c/headers-spec.js |
Adds warnings assertions and refactors status-based tests for header link behavior. |
src/w3c/templates/cgbg-headers.js |
Tweaks when the “Latest published version” row is rendered for CG/BG headers. |
src/w3c/headers.js |
Adds URL existence probing for latestVersion, refactors history derivation, and introduces resourceExists(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix [shortname] → [shortName] in docLink hint (wrong casing) - Move FPWD guard before resourceExists() fetch to avoid unnecessary network request for FPWD docs - Return null (not conf.historyURI) when historyURI is set on a non-standards-track document, so the History link is not rendered - Use cgbgStatus (not cgStatus) in the latestVersion loop test to cover BG-DRAFT status
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/w3c/templates/cgbg-headers.js:47
conf.latestVersion !== null(and the nestedconf.latestVersion !== "") will treatundefinedas “present” and render an<a>whose href/text becomeundefined. The W3C headers template avoids this by checking property existence ("latestVersion" in conf) and then treating falsy values as “none”. Consider aligning the CGBG template logic (e.g., guard on property existence or use a nullish check) so missing/undefinedlatestVersioncan’t produce a broken link.
${conf.latestVersion !== null
? html`<dt>${l10n.latest_published_version}</dt>
<dd>
${conf.latestVersion !== ""
? html`<a href="${conf.latestVersion}"
>${conf.latestVersion}</a
>`
: "none"}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sidvishnoi
reviewed
Apr 1, 2026
| </dd>` | ||
| : ""} | ||
| ${"latestVersion" in conf // latestVersion can be falsy | ||
| ${conf.latestVersion !== null |
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
edDraftURI,historyURI,implementationReportURI, and other header links are well-formed URLs pointing to the expected hostsTest plan
pnpm test:integration