diff --git a/src/sitemap/handler.js b/src/sitemap/handler.js index ee05ea9d..ad1ed46f 100644 --- a/src/sitemap/handler.js +++ b/src/sitemap/handler.js @@ -116,8 +116,15 @@ export async function checkRobotsForSitemap(protocol, domain, log) { * @returns {boolean} - True if the sitemap content is valid, otherwise false. */ export function isSitemapContentValid(sitemapContent) { - return sitemapContent.payload.trim().startsWith(' sitemapContent.type.includes(type)); + const payload = sitemapContent.payload.trim(); + + // Check if the content is HTML and return false if it is + if (payload.startsWith('') || payload.startsWith(' sitemapContent.type.includes(type)); } /** @@ -150,7 +157,7 @@ export async function checkSitemap(sitemapUrl, log) { const isValidFormat = isSitemapContentValid(sitemapContent); if (!isValidFormat) { - log.error(`Invalid sitemap format at ${sitemapUrl}`); + log.error(`Invalid sitemap format or non-sitemap content at ${sitemapUrl}`); return { existsAndIsValid: false, reasons: [ERROR_CODES.SITEMAP_FORMAT], @@ -158,6 +165,7 @@ export async function checkSitemap(sitemapUrl, log) { }; } + // Additional processing logic const isSitemapIndex = sitemapContent.payload.includes(''); const isText = sitemapContent.type === 'text/plain';