fix: align metadataRouteSuffix exemption list with Next.js#969
Conversation
…e#963) metadataRouteSuffix exempted robots and manifest in addition to sitemap, while getMetadataRouteSuffix only exempts sitemap (matching Next.js). This was latent because robots/manifest are nestable: false, but the inconsistency could cause subtle bugs if nestable ever changes. Remove the extra exemptions so both functions match Next.js exactly.
commit: |
|
/bigbonk review |
There was a problem hiding this comment.
LGTM. The change is correct and the reasoning is sound.
The old robots and manifest exemptions in metadataRouteSuffix were dead code — both types have nestable: false in METADATA_FILE_MAP, so the scan loop at line 527 (if (!config.nestable && urlPrefix !== "") continue) already ensures they only appear at root with an empty parentSegments. An empty array means hasInvisibleParent is always false, so the function would have returned "" anyway before reaching the hash computation.
Removing the dead exemptions to match getMetadataRouteSuffix (which only exempts sitemap, per the Next.js port) is the right call. One minor comment on the updated wording.
| if (metaType === "sitemap") { | ||
| // Sitemap is exempt per Next.js (robots/manifest are root-only, so | ||
| // invisible parents never apply — but we keep the exemption list | ||
| // matching getMetadataRouteSuffix for defensive consistency). |
There was a problem hiding this comment.
Nit: the comment says "we keep the exemption list matching getMetadataRouteSuffix" — but the whole point of this PR is that we changed the exemption list to match. The comment reads as if we intentionally kept something unchanged. Consider rewording:
| // matching getMetadataRouteSuffix for defensive consistency). | |
| // matching getMetadataRouteSuffix and Next.js for consistency). |
|
Review submitted. Here's a summary: Approved with one minor comment suggestion. The PR correctly removes dead Left one nit on the comment wording at line 467, suggesting a small tweak for clarity. |
Fixes #963
Summary
robotsandmanifestexemptions frommetadataRouteSuffixto matchgetMetadataRouteSuffixand Next.jssitemapfrom hash suffixesnestableever changesTest plan
tests/metadata-routes.test.ts(69 tests) passtests/app-router.test.tsmetadata tests pass