@ultimat3/seo 31.31.0 → 31.33.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/seo",
3
- "version": "31.31.0",
3
+ "version": "31.33.0",
4
4
  "description": "Enforced SEO: typed meta, JSON-LD, sitemap, robots, feeds, responsive images, perf budgets",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -43,7 +43,7 @@
43
43
  "test": "bun test"
44
44
  },
45
45
  "dependencies": {
46
- "@ultimat3/core": "31.31.0",
47
- "@ultimat3/schema": "31.31.0"
46
+ "@ultimat3/core": "31.33.0",
47
+ "@ultimat3/schema": "31.33.0"
48
48
  }
49
49
  }
package/src/links.ts CHANGED
@@ -1,9 +1,10 @@
1
- // `RouteMeta.links`: the `<link>` tags a route adds to `<head>` beyond the two this package
2
- // already derives (canonical, hreflang). A font preload, a preconnect, a feed. Typed so a rel the
3
- // framework owns elsewhere — `canonical` (`meta.canonical`), `stylesheet` (the surface bundle) —
4
- // is not spellable here, and checked so an href is always a URL a browser fetches: the value lands
5
- // in an attribute of the document every visitor loads, and `javascript:` in a `<link href>` is
6
- // script the page never meant to carry.
1
+ // `RouteMeta.links`: the `<link>` tags a route adds to `<head>` beyond the two this package already
2
+ // derives (canonical, hreflang). A font preload, a preconnect, a feed.
3
+ //
4
+ // Typed so a rel the framework owns elsewhere — `canonical` (`meta.canonical`), `stylesheet` (the
5
+ // surface bundle) — is not spellable here, and checked so an href is always a URL a browser
6
+ // fetches: the value lands in an attribute of the document every visitor loads, and `javascript:`
7
+ // in a `<link href>` is script the page never meant to carry.
7
8
 
8
9
  import { linkInvalid, type SeoError } from './errors';
9
10
  import type { HeadTag } from './meta';
@@ -8,13 +8,16 @@ import {
8
8
  type SitemapSectionConfig,
9
9
  sectionPatterns,
10
10
  sitemapSectionIssues,
11
+ trimTrailingSlashes,
11
12
  } from '@ultimat3/core';
12
13
 
13
14
  export type SitemapSection = SitemapSectionConfig;
14
15
 
15
16
  /** A page's path as a pattern reads it: no query, no fragment, no trailing slash. */
16
17
  function segmentsOf(path: string): readonly string[] {
17
- const bare = path.replace(/[?#].*$/, '').replace(/\/+$/, '');
18
+ // Cut at the first `?` or `#` by index, never `/[?#].*$/`: linear on every engine (CodeQL).
19
+ const cut = path.search(/[?#]/);
20
+ const bare = trimTrailingSlashes(cut === -1 ? path : path.slice(0, cut));
18
21
  return bare === '' ? [] : bare.slice(1).split('/');
19
22
  }
20
23
 
package/src/xml.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // file adds only what XML needs on top of it — the characters XML cannot carry at all — because a
3
3
  // sitemap, a feed and a <head> tag all fail the same way on an unescaped ampersand.
4
4
 
5
- import { escapeHtml } from '@ultimat3/core';
5
+ import { escapeHtml, trimTrailingSlashes } from '@ultimat3/core';
6
6
 
7
7
  /**
8
8
  * The characters XML 1.0 excludes from `Char`: the C0 controls other than tab, LF and CR, and the
@@ -58,7 +58,7 @@ export function attributes(attrs: Readonly<Record<string, string>>): string {
58
58
  */
59
59
  export function absoluteUrl(baseUrl: string, path: string): string {
60
60
  if (/^https?:\/\//.test(path)) return path;
61
- const base = baseUrl.replace(/\/+$/, '');
61
+ const base = trimTrailingSlashes(baseUrl);
62
62
  const rest = path.replace(/^\/+/, '');
63
63
  return rest === '' ? base : `${base}/${rest}`;
64
64
  }