@ultimat3/seo 31.33.0 → 31.35.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 +3 -3
- package/src/meta.ts +16 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/seo",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.35.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.
|
|
47
|
-
"@ultimat3/schema": "31.
|
|
46
|
+
"@ultimat3/core": "31.35.0",
|
|
47
|
+
"@ultimat3/schema": "31.35.0"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/meta.ts
CHANGED
|
@@ -159,11 +159,23 @@ export function localizedAlternates(
|
|
|
159
159
|
: [...cluster, { hreflang: 'x-default', href: fallback.path }];
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/** One separator a title template puts between the slot and the brand. */
|
|
163
|
+
const TEMPLATE_SEPARATOR = /[\s\-–—|·:>/]/;
|
|
164
|
+
|
|
162
165
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
166
|
+
* The template's BRAND: the slot removed and the separators around it stripped, so the
|
|
167
|
+
* containment test reads it: `'%s — Ultimate'` means the brand is `Ultimate`, not `— Ultimate`.
|
|
168
|
+
* Two index walks, never `/^[…]+|[…]+$/g`: its trailing half retried a separator run from each
|
|
169
|
+
* character of it — 9.2 s on a template of 100k spaces (CodeQL polynomial-redos).
|
|
165
170
|
*/
|
|
166
|
-
|
|
171
|
+
export function templateBrand(template: string): string {
|
|
172
|
+
const text = template.replace(TITLE_SLOT, '');
|
|
173
|
+
let start = 0;
|
|
174
|
+
let end = text.length;
|
|
175
|
+
while (start < end && TEMPLATE_SEPARATOR.test(text[start] ?? '')) start += 1;
|
|
176
|
+
while (end > start && TEMPLATE_SEPARATOR.test(text[end - 1] ?? '')) end -= 1;
|
|
177
|
+
return text.slice(start, end);
|
|
178
|
+
}
|
|
167
179
|
|
|
168
180
|
const WORD_CHARACTER = /[\p{L}\p{N}]/u;
|
|
169
181
|
|
|
@@ -202,7 +214,7 @@ export function applyTitleTemplate(title: string, template?: string): string {
|
|
|
202
214
|
// `renderMeta` runs per request, so the refusal belongs in `validate.ts`'s build gate, where it
|
|
203
215
|
// can name the file.
|
|
204
216
|
if (!template.includes(TITLE_SLOT)) return title;
|
|
205
|
-
const brand = template
|
|
217
|
+
const brand = templateBrand(template);
|
|
206
218
|
if (brand !== '' && containsWord(title, brand)) return title;
|
|
207
219
|
// A FUNCTION as the replacement, never the string: `replace` expands `$$`, `$&` and `$'` in a
|
|
208
220
|
// replacement literal, and a title is app data — "Save $$ on shoes" rendered one dollar.
|