Commit 7d76cb85 authored by Jiachi Liu's avatar Jiachi Liu

Revert "[metadata] use https protocol for schema urls" (#81934)

parent f9804004
...@@ -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>
" "
`) `)
}) })
}) })
......
...@@ -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="https://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="https://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="https://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="https://www.w3.org/1999/xhtml">\n' content += ' xmlns:xhtml="http://www.w3.org/1999/xhtml">\n'
} else { } else {
content += '>\n' content += '>\n'
} }
......
...@@ -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="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>
...@@ -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="https://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="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/about</loc> <loc>https://example.com/about</loc>
<video:video> <video:video>
......
...@@ -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 () => {
let html = await next.render('/') const 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="https://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>
......
...@@ -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="https://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>
......
...@@ -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="https://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="https://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="https://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="https://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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment