Skip to content

Commit

Permalink
chore: remove milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Dec 28, 2023
1 parent 75960b7 commit 6642e49
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/runtime/sitemap/urlset/normalise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function normaliseDate(d: Date | string) {
// lastmod must adhere to W3C Datetime encoding rules
if (typeof d === 'string') {
// we may have milliseconds at the end with a dot prefix like ".963745", we should remove this
d = d.replace('Z', '')
d = d.replace(/\.\d+$/, '')
// we may have a value like this "2023-12-21T13:49:27", this needs to be converted to w3c datetime
// accept if they are already in the right format, accept small format too such as "2023-12-21"
Expand Down
4 changes: 2 additions & 2 deletions test/integration/content/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('nuxt/content default', () => {
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://nuxtseo.com/blog/posts/bar</loc>
<lastmod>2021-10-20T00:00:00.000Z</lastmod>
<lastmod>2021-10-20T00:00:00</lastmod>
</url>
<url>
<loc>https://nuxtseo.com/blog/posts/fallback</loc>
<lastmod>2021-10-20T00:00:00.000Z</lastmod>
<lastmod>2021-10-20T00:00:00</lastmod>
</url>
</urlset>"
`)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/content/documentDriven.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ describe('nuxt/content documentDriven', () => {
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://nuxtseo.com/blog/posts/bar</loc>
<lastmod>2021-10-20T00:00:00.000Z</lastmod>
<lastmod>2021-10-20T00:00:00</lastmod>
</url>
<url>
<loc>https://nuxtseo.com/blog/posts/fallback</loc>
<lastmod>2021-10-20T00:00:00.000Z</lastmod>
<lastmod>2021-10-20T00:00:00</lastmod>
</url>
</urlset>"
`)
Expand Down

0 comments on commit 6642e49

Please sign in to comment.