From 818d9ce196eb6e931c379938e6a5c977b48abff1 Mon Sep 17 00:00:00 2001 From: paraschi Date: Tue, 20 Aug 2024 23:45:05 +0300 Subject: [PATCH] fix: unexpected close tag issue --- src/sitemap/handler.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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';