fix(sitemap): don't drop lastmod for an epoch (0) timestamp#12212
Open
durvesh1992 wants to merge 1 commit into
Open
fix(sitemap): don't drop lastmod for an epoch (0) timestamp#12212durvesh1992 wants to merge 1 commit into
durvesh1992 wants to merge 1 commit into
Conversation
getRouteLastUpdatedAt/getRouteLastmod used truthiness checks on the
numeric lastUpdatedAt, so a legitimate timestamp of 0 (1970-01-01, e.g.
from front matter last_update: {date: 1970-01-01}) was treated as 'no
value' and the <lastmod> entry was silently omitted. The adjacent
=== null guard already shows the intent to distinguish absent from
present. Use != null so 0 is preserved.
Adds a regression test (fails before / passes after).
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Motivation
createSitemapItemdecides a route's<lastmod>fromroute.metadata.lastUpdatedAt(a numeric timestamp, e.g. derived from front matterlast_update: {date: ...}). Two checks use truthiness on that number:So a legitimate timestamp of
0(1970-01-01T00:00:00Z) is treated as "no value" and the<lastmod>is silently omitted. The adjacent=== nullearly-return already shows the intent to distinguish absent from present — the truthiness checks defeat that for0.Fix
Use
!= nullin both places so0is preserved (while still treatingnull/undefinedas absent).Test plan
Added a regression test (
lastUpdatedAt: 0→lastmod: '1970-01-01') that fails before this change and passes after. Full sitemap package: 53 tests pass.