MCPcopy
hub / github.com/lissy93/web-check / sitemapHandler

Function sitemapHandler

api/sitemap.js:113–126  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

111};
112
113const sitemapHandler = async (url) => {
114 const origin = toOrigin(url);
115 let parsed = await tryFetch(`${origin}/sitemap.xml`, 'sitemap.xml');
116 if (!parsed) {
117 const fromRobots = await findSitemapInRobots(origin);
118 if (fromRobots) parsed = await tryFetch(fromRobots, 'robots-listed sitemap');
119 }
120 if (!parsed) return { skipped: 'No sitemap found for this site' };
121 try {
122 return slimResult(await expandSitemap(parsed, 0));
123 } catch (error) {
124 return upstreamError(error, 'Sitemap fetch');
125 }
126};
127
128export const handler = middleware(sitemapHandler);
129export default handler;

Callers

nothing calls this directly

Calls 6

upstreamErrorFunction · 0.90
toOriginFunction · 0.85
tryFetchFunction · 0.85
findSitemapInRobotsFunction · 0.85
slimResultFunction · 0.85
expandSitemapFunction · 0.85

Tested by

no test coverage detected