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

Function tryFetch

api/sitemap.js:102–111  ·  view source on GitHub ↗
(target, label)

Source from the content-addressed store, hash-verified

100
101// Try a candidate URL, return parsed result only when it looks like a real sitemap
102const tryFetch = async (target, label) => {
103 try {
104 const parsed = await fetchSitemap(target);
105 if (isValidSitemap(parsed)) return parsed;
106 log.debug(`${label} parsed but lacked urlset/sitemapindex (${target})`);
107 } catch (error) {
108 log.debug(`${label} fetch failed (${target})`, error.message);
109 }
110 return null;
111};
112
113const sitemapHandler = async (url) => {
114 const origin = toOrigin(url);

Callers 1

sitemapHandlerFunction · 0.85

Calls 2

fetchSitemapFunction · 0.85
isValidSitemapFunction · 0.85

Tested by

no test coverage detected