-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: filter i18n URLs based on non-prefixed path
- Loading branch information
Showing
3 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { createResolver } from '@nuxt/kit' | ||
import { $fetch, setup } from '@nuxt/test-utils' | ||
|
||
const { resolve } = createResolver(import.meta.url) | ||
|
||
await setup({ | ||
rootDir: resolve('../../fixtures/i18n'), | ||
nuxtConfig: { | ||
sitemap: { | ||
sitemaps: { | ||
foo: { | ||
urls: [ | ||
// custom blocked routes | ||
'/admin', | ||
'/es/admin', | ||
'/fr/admin', | ||
'/admin/foo', | ||
'/es/admin/foo', | ||
'/fr/admin/foo', | ||
'/admin/foo/bar', | ||
'/es/admin/foo/bar', | ||
'/fr/admin/foo/bar', | ||
// should be only route | ||
'/valid', | ||
], | ||
exclude: [ | ||
'/admin/**', | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
describe('multi filtering', () => { | ||
it('basic', async () => { | ||
let sitemap = await $fetch('/foo-sitemap.xml') | ||
|
||
// strip lastmod | ||
sitemap = sitemap.replace(/<lastmod>.*<\/lastmod>/g, '') | ||
|
||
expect(sitemap).toMatchInlineSnapshot(` | ||
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><?xml-stylesheet type=\\"text/xsl\\" href=\\"/__sitemap__/style.xsl\\"?> | ||
<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/valid</loc> | ||
</url> | ||
</urlset>" | ||
`) | ||
}, 60000) | ||
}) |