@se-studio/site-check 2.25.3 → 2.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.25.4
4
+
5
+ ### Patch Changes
6
+
7
+ - c82e3a6: Follow-up to the dotted From path fix. In 2.9.3, a From path with a dot is kept unless it ends in a static-asset extension, so `/.env`, `/.git`, `/wp-login.php`, `/backup.tar.gz` and `/feed.rss` were also kept; now they are rejected. `hasStaticAssetExtension` (core-data-types, re-exported by core-ui) also treats `.php`, `.gz` and `.rss` as files; the impossible-slug guard's own exemption list is unchanged, so a `.php` sitemap URL is still flagged. New `hasDotfileSegment` rejects any dotfile path segment except `/.well-known`. The site proxy template's trailing-slash helper now uses both, so `/blog/st.-louis` gets its 308 to `/blog/st.-louis/` while `/feed.xml` and `/.env` do not. site-check's sitemap parity stage now recognises a sitemap by its root element only (a prolog, comment, stylesheet or namespace prefix is fine; an HTML page that mentions `<urlset>` is not).
8
+ - Updated dependencies [c82e3a6]
9
+ - @se-studio/contentful-rest-api@2.9.4
10
+ - @se-studio/core-data-types@2.2.2
11
+ - @se-studio/core-ui@1.48.8
12
+
3
13
  ## 2.25.3
4
14
 
5
15
  ### Patch Changes
@@ -293,6 +293,21 @@ export function extractLocs(xml) {
293
293
  .filter(Boolean);
294
294
  }
295
295
 
296
+ /**
297
+ * What a sitemap body is, judged from its root element only: `'index'` (sitemapindex), `'urlset'`, or `null`
298
+ * (not a sitemap). The XML prolog (BOM, `<?xml ...?>`, processing instructions such as a stylesheet), comments
299
+ * and a DOCTYPE may come first; a namespace prefix is allowed and a self-closing root counts. A tag named
300
+ * inside a comment, an HTML page that mentions `<urlset>`, or `<urlsetx>` do not.
301
+ */
302
+ export function sitemapRootKind(text) {
303
+ const body = String(text)
304
+ .replace(/^\uFEFF/, '')
305
+ .replace(/^(?:\s+|<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!DOCTYPE[^>]*>)+/i, '');
306
+ const m = /^<(?:[A-Za-z_][\w.-]*:)?(sitemapindex|urlset)(?=[\s/>])/.exec(body);
307
+ if (!m) return null;
308
+ return m[1] === 'sitemapindex' ? 'index' : 'urlset';
309
+ }
310
+
296
311
  const STATIC_EXT_RE =
297
312
  /\.(?:png|jpe?g|gif|svg|webp|avif|ico|pdf|css|js|map|xml|txt|json|zip|mp4|webm|woff2?|ttf)$/i;
298
313
 
@@ -325,7 +340,8 @@ export async function collectRootPageUrls(
325
340
  const res = await fetchText(root);
326
341
  if (res.status < 200 || res.status >= 300)
327
342
  throw new Error(`sitemap root ${root} returned HTTP ${res.status}`);
328
- const isIndex = /<sitemapindex[\s>]/.test(res.text);
343
+ const rootKind = sitemapRootKind(res.text);
344
+ const isIndex = rootKind === 'index';
329
345
  const locs = extractLocs(res.text);
330
346
  const rootPages = [];
331
347
  if (!isIndex) {
@@ -339,13 +355,13 @@ export async function collectRootPageUrls(
339
355
  const c = await fetchText(child);
340
356
  if (c.status < 200 || c.status >= 300)
341
357
  throw new Error(`child sitemap ${child} of ${root} returned HTTP ${c.status}`);
342
- if (/<sitemapindex[\s>]/.test(c.text))
358
+ if (sitemapRootKind(c.text) === 'index')
343
359
  throw new Error(`child sitemap ${child} of ${root} is itself an index`);
344
360
  rootPages.push(...extractLocs(c.text));
345
361
  }
346
362
  }
347
363
  if (rootPages.length === 0) {
348
- const isSitemap = isIndex || /<urlset[\s>]/.test(res.text);
364
+ const isSitemap = rootKind !== null;
349
365
  if (!allowEmpty) throw new Error(`sitemap root ${root} lists no URLs`);
350
366
  if (!isSitemap) throw new Error(`sitemap root ${root} is not a sitemap`);
351
367
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/site-check",
3
- "version": "2.25.3",
3
+ "version": "2.25.4",
4
4
  "description": "Validate SE marketing sites (sitemap, llms.txt) and download markdown files preserving structure",
5
5
  "repository": {
6
6
  "type": "git",
@@ -110,9 +110,9 @@
110
110
  "url": "https://github.com/Something-Else-Studio/se-core-product/issues"
111
111
  },
112
112
  "dependencies": {
113
- "@se-studio/contentful-rest-api": "2.9.3",
114
- "@se-studio/core-data-types": "2.2.1",
115
- "@se-studio/core-ui": "1.48.7"
113
+ "@se-studio/contentful-rest-api": "2.9.4",
114
+ "@se-studio/core-data-types": "2.2.2",
115
+ "@se-studio/core-ui": "1.48.8"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@biomejs/biome": "^2.6.8",