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
7d76cb85
Commit
7d76cb85
authored
Jul 22, 2025
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "[metadata] use https protocol for schema urls" (#81934)
parent
f9804004
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
76 deletions
+76
-76
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
index.test.ts
.../middleware-sitemap/matcher-exclude-sitemap/index.test.ts
+2
-2
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 @
7d76cb85
...
@@ -87,16 +87,16 @@ describe('resolveRouteData', () => {
...
@@ -87,16 +87,16 @@ describe('resolveRouteData', () => {
},
},
])
])
).
toMatchInlineSnapshot
(
`
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http
://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://example.com</loc>
<loc>https://example.com</loc>
<lastmod>2021-01-01</lastmod>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
<priority>0.5</priority>
</url>
</url>
</urlset>
</urlset>
"
"
`
)
`
)
})
})
it
(
'should resolve sitemap.xml with alternates'
,
()
=>
{
it
(
'should resolve sitemap.xml with alternates'
,
()
=>
{
...
@@ -114,16 +114,16 @@ describe('resolveRouteData', () => {
...
@@ -114,16 +114,16 @@ describe('resolveRouteData', () => {
},
},
])
])
).
toMatchInlineSnapshot
(
`
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?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">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http
://www.w3.org/1999/xhtml">
<url>
<url>
<loc>https://example.com</loc>
<loc>https://example.com</loc>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es" />
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es" />
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de" />
<lastmod>2021-01-01</lastmod>
<lastmod>2021-01-01</lastmod>
</url>
</url>
</urlset>
</urlset>
"
"
`
)
`
)
})
})
it
(
'should resolve sitemap.xml with images'
,
()
=>
{
it
(
'should resolve sitemap.xml with images'
,
()
=>
{
...
@@ -138,19 +138,19 @@ describe('resolveRouteData', () => {
...
@@ -138,19 +138,19 @@ describe('resolveRouteData', () => {
},
},
])
])
).
toMatchInlineSnapshot
(
`
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?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">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http
://www.google.com/schemas/sitemap-image/1.1">
<url>
<url>
<loc>https://example.com</loc>
<loc>https://example.com</loc>
<image:image>
<image:image>
<image:loc>https://example.com/image.jpg</image:loc>
<image:loc>https://example.com/image.jpg</image:loc>
</image:image>
</image:image>
<lastmod>2021-01-01</lastmod>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
<priority>0.5</priority>
</url>
</url>
</urlset>
</urlset>
"
"
`
)
`
)
})
})
it
(
'should resolve sitemap.xml with videos'
,
()
=>
{
it
(
'should resolve sitemap.xml with videos'
,
()
=>
{
...
@@ -194,35 +194,35 @@ describe('resolveRouteData', () => {
...
@@ -194,35 +194,35 @@ describe('resolveRouteData', () => {
},
},
])
])
).
toMatchInlineSnapshot
(
`
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?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">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http
://www.google.com/schemas/sitemap-video/1.1">
<url>
<url>
<loc>https://example.com</loc>
<loc>https://example.com</loc>
<video:video>
<video:video>
<video:title>example</video:title>
<video:title>example</video:title>
<video:thumbnail_loc>https://example.com/image.jpg</video:thumbnail_loc>
<video:thumbnail_loc>https://example.com/image.jpg</video:thumbnail_loc>
<video:description>this is the description</video:description>
<video:description>this is the description</video:description>
<video:content_loc>http://streamserver.example.com/video123.mp4</video:content_loc>
<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:player_loc>https://www.example.com/videoplayer.php?video=123</video:player_loc>
<video:duration>2</video:duration>
<video:duration>2</video:duration>
<video:view_count>50</video:view_count>
<video:view_count>50</video:view_count>
<video:tag>summer</video:tag>
<video:tag>summer</video:tag>
<video:rating>4</video:rating>
<video:rating>4</video:rating>
<video:expiration_date>2025-09-16</video:expiration_date>
<video:expiration_date>2025-09-16</video:expiration_date>
<video:publication_date>2024-09-16</video:publication_date>
<video:publication_date>2024-09-16</video:publication_date>
<video:family_friendly>yes</video:family_friendly>
<video:family_friendly>yes</video:family_friendly>
<video:requires_subscription>no</video:requires_subscription>
<video:requires_subscription>no</video:requires_subscription>
<video:live>no</video:live>
<video:live>no</video:live>
<video:restriction relationship="allow">IE GB US CA</video:restriction>
<video:restriction relationship="allow">IE GB US CA</video:restriction>
<video:platform relationship="allow">web</video:platform>
<video:platform relationship="allow">web</video:platform>
<video:uploader info="https://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>
<video:uploader info="https://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>
</video:video>
</video:video>
<lastmod>2021-01-01</lastmod>
<lastmod>2021-01-01</lastmod>
<changefreq>weekly</changefreq>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
<priority>0.5</priority>
</url>
</url>
</urlset>
</urlset>
"
"
`
)
`
)
})
})
})
})
...
...
packages/next/src/build/webpack/loaders/metadata/resolve-route-data.ts
View file @
7d76cb85
...
@@ -52,15 +52,15 @@ export function resolveSitemap(data: MetadataRoute.Sitemap): string {
...
@@ -52,15 +52,15 @@ export function resolveSitemap(data: MetadataRoute.Sitemap): string {
let
content
=
''
let
content
=
''
content
+=
'<?xml version="1.0" encoding="UTF-8"?>
\
n'
content
+=
'<?xml version="1.0" encoding="UTF-8"?>
\
n'
content
+=
'<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9"'
content
+=
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'
if
(
hasImages
)
{
if
(
hasImages
)
{
content
+=
' xmlns:image="http
s
://www.google.com/schemas/sitemap-image/1.1"'
content
+=
' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'
}
}
if
(
hasVideos
)
{
if
(
hasVideos
)
{
content
+=
' xmlns:video="http
s
://www.google.com/schemas/sitemap-video/1.1"'
content
+=
' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"'
}
}
if
(
hasAlternates
)
{
if
(
hasAlternates
)
{
content
+=
' xmlns:xhtml="http
s
://www.w3.org/1999/xhtml">
\
n'
content
+=
' xmlns:xhtml="http://www.w3.org/1999/xhtml">
\
n'
}
else
{
}
else
{
content
+=
'>
\
n'
content
+=
'>
\
n'
}
}
...
...
test/e2e/app-dir/metadata-dynamic-routes/index.test.ts
View file @
7d76cb85
...
@@ -52,7 +52,7 @@ describe('app dir - metadata dynamic routes', () => {
...
@@ -52,7 +52,7 @@ describe('app dir - metadata dynamic routes', () => {
expect
(
text
).
toMatchInlineSnapshot
(
`
expect
(
text
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://example.com</loc>
<loc>https://example.com</loc>
<lastmod>2021-01-01</lastmod>
<lastmod>2021-01-01</lastmod>
...
@@ -95,7 +95,7 @@ describe('app dir - metadata dynamic routes', () => {
...
@@ -95,7 +95,7 @@ describe('app dir - metadata dynamic routes', () => {
it
(
'should support alternate.languages in sitemap'
,
async
()
=>
{
it
(
'should support alternate.languages in sitemap'
,
async
()
=>
{
const
xml
=
await
(
await
next
.
fetch
(
'/lang/sitemap.xml'
)).
text
()
const
xml
=
await
(
await
next
.
fetch
(
'/lang/sitemap.xml'
)).
text
()
expect
(
xml
).
toContain
(
'xmlns:xhtml="http
s
://www.w3.org/1999/xhtml'
)
expect
(
xml
).
toContain
(
'xmlns:xhtml="http://www.w3.org/1999/xhtml'
)
expect
(
xml
).
toContain
(
expect
(
xml
).
toContain
(
`<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/about" />`
`<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/about" />`
)
)
...
@@ -119,7 +119,7 @@ describe('app dir - metadata dynamic routes', () => {
...
@@ -119,7 +119,7 @@ describe('app dir - metadata dynamic routes', () => {
const
xml
=
await
(
await
next
.
fetch
(
'/sitemap-video/sitemap.xml'
)).
text
()
const
xml
=
await
(
await
next
.
fetch
(
'/sitemap-video/sitemap.xml'
)).
text
()
expect
(
xml
).
toMatchInlineSnapshot
(
`
expect
(
xml
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="https
://www.google.com/schemas/sitemap-video/1.1">
<urlset xmlns="http
://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http
://www.google.com/schemas/sitemap-video/1.1">
<url>
<url>
<loc>https://example.com/about</loc>
<loc>https://example.com/about</loc>
<video:video>
<video:video>
...
...
test/e2e/app-dir/middleware-sitemap/matcher-exclude-sitemap/index.test.ts
View file @
7d76cb85
...
@@ -6,13 +6,13 @@ describe('middleware-sitemap', () => {
...
@@ -6,13 +6,13 @@ describe('middleware-sitemap', () => {
})
})
it
(
'should not be affected by middleware if sitemap.xml is excluded from the matcher'
,
async
()
=>
{
it
(
'should not be affected by middleware if sitemap.xml is excluded from the matcher'
,
async
()
=>
{
le
t
html
=
await
next
.
render
(
'/'
)
cons
t
html
=
await
next
.
render
(
'/'
)
expect
(
html
).
toContain
(
'redirected'
)
expect
(
html
).
toContain
(
'redirected'
)
const
xml
=
await
next
.
render
(
'/sitemap.xml'
)
const
xml
=
await
next
.
render
(
'/sitemap.xml'
)
expect
(
xml
).
toMatchInlineSnapshot
(
`
expect
(
xml
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://vercel.com</loc>
<loc>https://vercel.com</loc>
<lastmod>2023-10-01</lastmod>
<lastmod>2023-10-01</lastmod>
...
...
test/e2e/app-dir/sitemap-group/sitemap-group.test.ts
View file @
7d76cb85
...
@@ -12,7 +12,7 @@ describe('sitemap-group', () => {
...
@@ -12,7 +12,7 @@ describe('sitemap-group', () => {
const
text
=
await
res
.
text
()
const
text
=
await
res
.
text
()
expect
(
text
).
toMatchInlineSnapshot
(
`
expect
(
text
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://www.vercel.com</loc>
<loc>https://www.vercel.com</loc>
<lastmod>2024-12-05T23:45:13.405Z</lastmod>
<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 @
7d76cb85
...
@@ -44,7 +44,7 @@ describe('use-cache-metadata-route-handler', () => {
...
@@ -44,7 +44,7 @@ describe('use-cache-metadata-route-handler', () => {
if
(
isNextDev
)
{
if
(
isNextDev
)
{
expect
(
body
).
toMatchInlineSnapshot
(
`
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://acme.com?sentinel=runtime</loc>
<loc>https://acme.com?sentinel=runtime</loc>
</url>
</url>
...
@@ -54,7 +54,7 @@ describe('use-cache-metadata-route-handler', () => {
...
@@ -54,7 +54,7 @@ describe('use-cache-metadata-route-handler', () => {
}
else
{
}
else
{
expect
(
body
).
toMatchInlineSnapshot
(
`
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://acme.com?sentinel=buildtime</loc>
<loc>https://acme.com?sentinel=buildtime</loc>
</url>
</url>
...
@@ -74,7 +74,7 @@ describe('use-cache-metadata-route-handler', () => {
...
@@ -74,7 +74,7 @@ describe('use-cache-metadata-route-handler', () => {
if
(
isNextDev
)
{
if
(
isNextDev
)
{
expect
(
body
).
toMatchInlineSnapshot
(
`
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://acme.com/1?sentinel=runtime</loc>
<loc>https://acme.com/1?sentinel=runtime</loc>
</url>
</url>
...
@@ -84,7 +84,7 @@ describe('use-cache-metadata-route-handler', () => {
...
@@ -84,7 +84,7 @@ describe('use-cache-metadata-route-handler', () => {
}
else
{
}
else
{
expect
(
body
).
toMatchInlineSnapshot
(
`
expect
(
body
).
toMatchInlineSnapshot
(
`
"<?xml version="1.0" encoding="UTF-8"?>
"<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http
s
://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<url>
<loc>https://acme.com/1?sentinel=buildtime</loc>
<loc>https://acme.com/1?sentinel=buildtime</loc>
</url>
</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