Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions tests/sites/etusivu/sitemap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ const testUrls = (request: APIRequestContext, pageUrls: string[], path: string)
);
});

/**
* Check if the sitemap is a sitemap index.
*
* @param xml
* The XML content of the sitemap.
* @returns True if the sitemap is a sitemap index, false otherwise.
*/
const hasSitemapIndex = (xml: string): boolean => {
return /<\s*sitemapindex\b/i.test(xml);
};

/**
* Tests a multipage sitemap.
*
Expand Down Expand Up @@ -104,8 +115,11 @@ test('Sitemap', async ({ request, baseURL }) => {

// Handle front page separately, as it's a multipage sitemap.
if (isFrontPage) {
await testMultiPageSitemap(request, response, path);
return;
const sitemapXml = await response.text();
if (hasSitemapIndex(sitemapXml)) {
await testMultiPageSitemap(request, response, path);
return;
}
}

// Handle normal sitemap.
Expand Down