Skip to content

Commit

Permalink
feat: rename fct
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiAlexandruParaschiv committed Aug 13, 2024
1 parent bd74df4 commit cb62cff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sitemap/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export async function checkSitemap(sitemapUrl) {
* @param {Array<string>} urls - Array of URLs to check.
* @returns {Promise<Array<string>>} - List of sitemap URLs that exist.
*/
async function checkCommonSitemapUrls(urls) {
async function filterValidUrls(urls) {
const fetchPromises = urls.map(async (url) => {
const response = await fetch(url, { method: 'HEAD' });
return response.ok ? url : null;
Expand Down Expand Up @@ -264,7 +264,7 @@ export async function findSitemap(inputUrl) {

if (!sitemapUrls.length) {
const commonSitemapUrls = [`${protocol}://${domain}/sitemap.xml`, `${protocol}://${domain}/sitemap_index.xml`];
sitemapUrls = await checkCommonSitemapUrls(commonSitemapUrls);
sitemapUrls = await filterValidUrls(commonSitemapUrls);
if (!sitemapUrls.length) {
logMessages.push({ value: `No sitemap found in robots.txt or common paths for ${protocol}://${domain}`, error: ERROR_CODES.NO_SITEMAP_IN_ROBOTS });
return { success: false, reasons: logMessages };
Expand All @@ -283,7 +283,7 @@ export async function findSitemap(inputUrl) {
for (const s of extractedSitemapUrls) {
const urlsToCheck = extractedPaths[s];
// eslint-disable-next-line no-await-in-loop
const existingPages = await checkCommonSitemapUrls(urlsToCheck);
const existingPages = await filterValidUrls(urlsToCheck);

if (existingPages.length === 0) {
delete extractedPaths[s];
Expand Down

0 comments on commit cb62cff

Please sign in to comment.