(url)
| 111 | }; |
| 112 | |
| 113 | const 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 | |
| 128 | export const handler = middleware(sitemapHandler); |
| 129 | export default handler; |
nothing calls this directly
no test coverage detected