Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
27259738
Unverified
Commit
27259738
authored
Jun 10, 2025
by
Jiachi Liu
Committed by
GitHub
Jun 10, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[metadata] use https protocol for schema urls (#80356)
parent
1f3a186a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
81 deletions
+88
-81
resolve-route-data.test.ts
...build/webpack/loaders/metadata/resolve-route-data.test.ts
+62
-62
resolve-route-data.ts
.../src/build/webpack/loaders/metadata/resolve-route-data.ts
+4
-4
index.test.ts
test/e2e/app-dir/metadata-dynamic-routes/index.test.ts
+3
-3
sitemap.ts
...middleware-sitemap/matcher-exclude-sitemap/app/sitemap.ts
+1
-1
index.test.ts
.../middleware-sitemap/matcher-exclude-sitemap/index.test.ts
+13
-6
sitemap-group.test.ts
test/e2e/app-dir/sitemap-group/sitemap-group.test.ts
+1
-1
use-cache-metadata-route-handler.test.ts
...ta-route-handler/use-cache-metadata-route-handler.test.ts
+4
-4
No files found.
packages/next/src/build/webpack/loaders/metadata/resolve-route-data.test.ts
View file @
27259738
...
...
@@ -87,16 +87,16 @@ describe('resolveRouteData', () => {
},
])
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com</loc>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
"
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com</loc>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
"
`
)
})
it
(
'should resolve sitemap.xml with alternates'
,
()
=>
{
...
...
@@ -114,16 +114,16 @@ describe('resolveRouteData', () => {
},
])
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http
://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com</loc>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es" />
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<lastmod>2021-01-01</lastmod>
</url>
</urlset>
"
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https
://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com</loc>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es" />
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<lastmod>2021-01-01</lastmod>
</url>
</urlset>
"
`
)
})
it
(
'should resolve sitemap.xml with images'
,
()
=>
{
...
...
@@ -138,19 +138,19 @@ describe('resolveRouteData', () => {
},
])
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http
://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.com</loc>
<image:image>
<image:loc>https://example.com/image.jpg</image:loc>
</image:image>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
"
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="https
://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.com</loc>
<image:image>
<image:loc>https://example.com/image.jpg</image:loc>
</image:image>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
"
`
)
})
it
(
'should resolve sitemap.xml with videos'
,
()
=>
{
...
...
@@ -194,35 +194,35 @@ describe('resolveRouteData', () => {
},
])
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http
://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://example.com</loc>
<video:video>
<video:title>example</video:title>
<video:thumbnail_loc>https://example.com/image.jpg</video:thumbnail_loc>
<video:description>this is the description</video:description>
<video:content_loc>http://streamserver.example.com/video123.mp4</video:content_loc>
<video:player_loc>https://www.example.com/videoplayer.php?video=123</video:player_loc>
<video:duration>2</video:duration>
<video:view_count>50</video:view_count>
<video:tag>summer</video:tag>
<video:rating>4</video:rating>
<video:expiration_date>2025-09-16</video:expiration_date>
<video:publication_date>2024-09-16</video:publication_date>
<video:family_friendly>yes</video:family_friendly>
<video:requires_subscription>no</video:requires_subscription>
<video:live>no</video:live>
<video:restriction relationship="allow">IE GB US CA</video:restriction>
<video:platform relationship="allow">web</video:platform>
<video:uploader info="https://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>
</video:video>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
"
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="https
://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://example.com</loc>
<video:video>
<video:title>example</video:title>
<video:thumbnail_loc>https://example.com/image.jpg</video:thumbnail_loc>
<video:description>this is the description</video:description>
<video:content_loc>http://streamserver.example.com/video123.mp4</video:content_loc>
<video:player_loc>https://www.example.com/videoplayer.php?video=123</video:player_loc>
<video:duration>2</video:duration>
<video:view_count>50</video:view_count>
<video:tag>summer</video:tag>
<video:rating>4</video:rating>
<video:expiration_date>2025-09-16</video:expiration_date>
<video:publication_date>2024-09-16</video:publication_date>
<video:family_friendly>yes</video:family_friendly>
<video:requires_subscription>no</video:requires_subscription>
<video:live>no</video:live>
<video:restriction relationship="allow">IE GB US CA</video:restriction>
<video:platform relationship="allow">web</video:platform>
<video:uploader info="https://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>
</video:video>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
"
`
)
})
})
...
...
packages/next/src/build/webpack/loaders/metadata/resolve-route-data.ts
View file @
27259738
...
...
@@ -52,15 +52,15 @@ export function resolveSitemap(data: MetadataRoute.Sitemap): string {
let
content
=
''
content
+=
'<?xml version="1.0" encoding="UTF-8"?>
\
n'
content
+=
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'
content
+=
'<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9"'
if
(
hasImages
)
{
content
+=
' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'
content
+=
' xmlns:image="http
s
://www.google.com/schemas/sitemap-image/1.1"'
}
if
(
hasVideos
)
{
content
+=
' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"'
content
+=
' xmlns:video="http
s
://www.google.com/schemas/sitemap-video/1.1"'
}
if
(
hasAlternates
)
{
content
+=
' xmlns:xhtml="http://www.w3.org/1999/xhtml">
\
n'
content
+=
' xmlns:xhtml="http
s
://www.w3.org/1999/xhtml">
\
n'
}
else
{
content
+=
'>
\
n'
}
...
...
test/e2e/app-dir/metadata-dynamic-routes/index.test.ts
View file @
27259738
...
...
@@ -52,7 +52,7 @@ describe('app dir - metadata dynamic routes', () => {
expect
(
text
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com</loc>
<lastmod>2021-01-01</lastmod>
...
...
@@ -95,7 +95,7 @@ describe('app dir - metadata dynamic routes', () => {
it
(
'should support alternate.languages in sitemap'
,
async
()
=>
{
const
xml
=
await
(
await
next
.
fetch
(
'/lang/sitemap.xml'
)).
text
()
expect
(
xml
).
toContain
(
'xmlns:xhtml="http://www.w3.org/1999/xhtml'
)
expect
(
xml
).
toContain
(
'xmlns:xhtml="http
s
://www.w3.org/1999/xhtml'
)
expect
(
xml
).
toContain
(
`<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/about" />`
)
...
...
@@ -119,7 +119,7 @@ describe('app dir - metadata dynamic routes', () => {
const
xml
=
await
(
await
next
.
fetch
(
'/sitemap-video/sitemap.xml'
)).
text
()
expect
(
xml
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http
://www.google.com/schemas/sitemap-video/1.1">
<urlset xmlns="http
s://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="https
://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://example.com/about</loc>
<video:video>
...
...
test/e2e/app-dir/middleware-sitemap/matcher-exclude-sitemap/app/sitemap.ts
View file @
27259738
...
...
@@ -4,7 +4,7 @@ export default function sitemap(): MetadataRoute.Sitemap {
return
[
{
url
:
'https://vercel.com'
,
lastModified
:
new
Date
()
,
lastModified
:
'2023-10-01'
,
changeFrequency
:
'yearly'
,
priority
:
1
,
},
...
...
test/e2e/app-dir/middleware-sitemap/matcher-exclude-sitemap/index.test.ts
View file @
27259738
...
...
@@ -9,11 +9,18 @@ describe('middleware-sitemap', () => {
let
html
=
await
next
.
render
(
'/'
)
expect
(
html
).
toContain
(
'redirected'
)
html
=
await
next
.
render
(
'/sitemap.xml'
)
expect
(
html
).
not
.
toContain
(
'redirected'
)
expect
(
html
).
toContain
(
'<?xml version="1.0" encoding="UTF-8"?>'
)
expect
(
html
).
toContain
(
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
)
const
xml
=
await
next
.
render
(
'/sitemap.xml'
)
expect
(
xml
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://vercel.com</loc>
<lastmod>2023-10-01</lastmod>
<changefreq>yearly</changefreq>
<priority>1</priority>
</url>
</urlset>
"
`
)
})
})
test/e2e/app-dir/sitemap-group/sitemap-group.test.ts
View file @
27259738
...
...
@@ -12,7 +12,7 @@ describe('sitemap-group', () => {
const
text
=
await
res
.
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.vercel.com</loc>
<lastmod>2024-12-05T23:45:13.405Z</lastmod>
...
...
test/e2e/app-dir/use-cache-metadata-route-handler/use-cache-metadata-route-handler.test.ts
View file @
27259738
...
...
@@ -44,7 +44,7 @@ describe('use-cache-metadata-route-handler', () => {
if
(
isNextDev
)
{
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://acme.com?sentinel=runtime</loc>
</url>
...
...
@@ -54,7 +54,7 @@ describe('use-cache-metadata-route-handler', () => {
}
else
{
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://acme.com?sentinel=buildtime</loc>
</url>
...
...
@@ -74,7 +74,7 @@ describe('use-cache-metadata-route-handler', () => {
if
(
isNextDev
)
{
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://acme.com/1?sentinel=runtime</loc>
</url>
...
...
@@ -84,7 +84,7 @@ describe('use-cache-metadata-route-handler', () => {
}
else
{
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://acme.com/1?sentinel=buildtime</loc>
</url>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment