mcp-web-validator 1.3.50 → 1.3.53
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 +53 -0
- package/README.md +66 -4
- package/dist/audit-history.d.ts +9 -0
- package/dist/audit-history.js +27 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +2535 -30
- package/dist/index.js.map +1 -1
- package/dist/mcp-bounds.d.ts +11 -0
- package/dist/mcp-bounds.js +68 -0
- package/dist/mcp-bounds.js.map +1 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.d.ts +21 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +190 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -0
- package/dist/modules/browser-ux/lighthouse-lab.d.ts +61 -0
- package/dist/modules/browser-ux/lighthouse-lab.js +98 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -0
- package/dist/modules/browser-ux/media-diagnostics.d.ts +41 -0
- package/dist/modules/browser-ux/media-diagnostics.js +183 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-diff.d.ts +70 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js +262 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-probe.d.ts +17 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js +163 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures-probe.d.ts +11 -0
- package/dist/modules/browser-ux/resource-failures-probe.js +231 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures.d.ts +79 -0
- package/dist/modules/browser-ux/resource-failures.js +178 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity-probe.d.ts +5 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js +307 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity.d.ts +112 -0
- package/dist/modules/browser-ux/viewport-parity.js +224 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -0
- package/dist/modules/browser-ux/wcag-interactions.d.ts +95 -0
- package/dist/modules/browser-ux/wcag-interactions.js +360 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -0
- package/dist/modules/change-regression/availability-history-store.d.ts +18 -0
- package/dist/modules/change-regression/availability-history-store.js +168 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -0
- package/dist/modules/change-regression/crawler-log-correlation.d.ts +111 -0
- package/dist/modules/change-regression/crawler-log-correlation.js +374 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -0
- package/dist/modules/change-regression/google-common-crawler-ip.d.ts +15 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js +129 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -0
- package/dist/modules/change-regression/historical-comparisons.d.ts +120 -0
- package/dist/modules/change-regression/historical-comparisons.js +330 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -0
- package/dist/modules/change-regression/production-change-comparison.d.ts +68 -0
- package/dist/modules/change-regression/production-change-comparison.js +214 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -0
- package/dist/modules/change-regression/regression-alerts.d.ts +73 -0
- package/dist/modules/change-regression/regression-alerts.js +183 -0
- package/dist/modules/change-regression/regression-alerts.js.map +1 -0
- package/dist/modules/change-regression/strict-observation-time.d.ts +7 -0
- package/dist/modules/change-regression/strict-observation-time.js +31 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -0
- package/dist/modules/content-schema/citation-methodology-consistency.d.ts +108 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js +360 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -0
- package/dist/modules/content-schema/competitor-intent-comparison.d.ts +74 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js +185 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -0
- package/dist/modules/content-schema/empty-boilerplate-content.d.ts +36 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js +225 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -0
- package/dist/modules/content-schema/extract-citation-methodology.d.ts +6 -0
- package/dist/modules/content-schema/extract-citation-methodology.js +201 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -0
- package/dist/modules/content-schema/extract-competitor-intent.d.ts +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js +140 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -0
- package/dist/modules/content-schema/extract-main-content.d.ts +6 -0
- package/dist/modules/content-schema/extract-main-content.js +33 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -0
- package/dist/modules/content-schema/extract-metadata-consistency.d.ts +3 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js +62 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/extract-product-claims.d.ts +3 -0
- package/dist/modules/content-schema/extract-product-claims.js +58 -0
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -0
- package/dist/modules/content-schema/extract-structured-data.d.ts +3 -0
- package/dist/modules/content-schema/extract-structured-data.js +25 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -0
- package/dist/modules/content-schema/metadata-consistency.d.ts +66 -0
- package/dist/modules/content-schema/metadata-consistency.js +282 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/product-claims.d.ts +73 -0
- package/dist/modules/content-schema/product-claims.js +195 -0
- package/dist/modules/content-schema/product-claims.js.map +1 -0
- package/dist/modules/content-schema/same-language-duplicates.d.ts +52 -0
- package/dist/modules/content-schema/same-language-duplicates.js +158 -0
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -0
- package/dist/modules/content-schema/structured-data-validation.d.ts +37 -0
- package/dist/modules/content-schema/structured-data-validation.js +385 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -0
- package/dist/modules/external-metrics/crux-field-probe.d.ts +10 -0
- package/dist/modules/external-metrics/crux-field-probe.js +113 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -0
- package/dist/modules/external-metrics/crux-field.d.ts +61 -0
- package/dist/modules/external-metrics/crux-field.js +231 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -0
- package/dist/modules/http-crawl/availability-observations.d.ts +68 -0
- package/dist/modules/http-crawl/availability-observations.js +206 -0
- package/dist/modules/http-crawl/availability-observations.js.map +1 -0
- package/dist/modules/http-crawl/availability-probe.d.ts +8 -0
- package/dist/modules/http-crawl/availability-probe.js +46 -0
- package/dist/modules/http-crawl/availability-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access-probe.d.ts +6 -0
- package/dist/modules/http-crawl/crawler-access-probe.js +79 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access.d.ts +75 -0
- package/dist/modules/http-crawl/crawler-access.js +404 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery-probe.d.ts +3 -0
- package/dist/modules/http-crawl/http-delivery-probe.js +44 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery.d.ts +64 -0
- package/dist/modules/http-crawl/http-delivery.js +269 -0
- package/dist/modules/http-crawl/http-delivery.js.map +1 -0
- package/dist/modules/http-crawl/https-security.d.ts +84 -0
- package/dist/modules/http-crawl/https-security.js +441 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -0
- package/dist/modules/http-crawl/non-html-directives.d.ts +74 -0
- package/dist/modules/http-crawl/non-html-directives.js +353 -0
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.d.ts +80 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js +459 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.d.ts +6 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js +83 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.d.ts +8 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +155 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory.d.ts +107 -0
- package/dist/modules/http-crawl/sitemap-inventory.js +557 -0
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -0
- package/dist/modules/http-crawl/url-variants.d.ts +86 -0
- package/dist/modules/http-crawl/url-variants.js +379 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -0
- package/dist/modules/site-architecture/extract-internal-links.d.ts +3 -0
- package/dist/modules/site-architecture/extract-internal-links.js +88 -0
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -0
- package/dist/modules/site-architecture/extract-multilingual-page.d.ts +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js +29 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.d.ts +7 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js +116 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph.d.ts +113 -0
- package/dist/modules/site-architecture/internal-link-graph.js +414 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-quality.d.ts +77 -0
- package/dist/modules/site-architecture/internal-link-quality.js +260 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -0
- package/dist/modules/site-architecture/multilingual-clusters.d.ts +82 -0
- package/dist/modules/site-architecture/multilingual-clusters.js +363 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -0
- package/dist/network.d.ts +4 -0
- package/dist/network.js +18 -2
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +53 -0
- package/dist/presentation.js +526 -0
- package/dist/presentation.js.map +1 -1
- package/dist/screenshot.d.ts +2 -1
- package/dist/screenshot.js +4 -2
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +16 -6
- package/dist/seo-auditor.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1-02: bounded hreflang and canonical cluster verification.
|
|
3
|
+
*
|
|
4
|
+
* Pure local/Worker logic over explicitly supplied static HTML observations.
|
|
5
|
+
* Never fetch a referenced URL, infer Google's canonical choice, or echo
|
|
6
|
+
* credentialed/query-bearing links.
|
|
7
|
+
*/
|
|
8
|
+
export const MAX_MULTILINGUAL_PAGES = 16;
|
|
9
|
+
export const MAX_HREFLANG_LOCALES = 16;
|
|
10
|
+
export const MAX_HREFLANG_DECLARATIONS_SCANNED = 64;
|
|
11
|
+
export const MAX_MULTILINGUAL_FINDINGS = 12;
|
|
12
|
+
const MAX_PUBLIC_LABEL_CHARS = 256;
|
|
13
|
+
export const MAX_MULTILINGUAL_HTML_CHARS = 250_000;
|
|
14
|
+
const MAX_EXAMPLE_URLS = 2;
|
|
15
|
+
const REGION_CODES_RESERVED = new Set(["EU", "UN", "UK", "ZZ"]);
|
|
16
|
+
const regions = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
17
|
+
const languages = new Intl.DisplayNames(["en"], { type: "language", fallback: "none" });
|
|
18
|
+
const scripts = new Intl.DisplayNames(["en"], { type: "script", fallback: "none" });
|
|
19
|
+
/** Deliberately require absolute, query-free references rather than masking changes in targets. */
|
|
20
|
+
export function safeMultilingualUrl(raw) {
|
|
21
|
+
if (raw.length === 0 || raw.length > MAX_PUBLIC_LABEL_CHARS)
|
|
22
|
+
return undefined;
|
|
23
|
+
try {
|
|
24
|
+
const url = new URL(raw);
|
|
25
|
+
if ((url.protocol !== "https:" && url.protocol !== "http:") ||
|
|
26
|
+
!url.hostname || url.username || url.password || url.search || url.hash || url.port) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return url.href;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Accept Google's documented HTML hreflang forms: ISO 639-1 language, optional
|
|
37
|
+
* ISO 15924 script, optional ISO 3166-1 alpha-2 region, and x-default.
|
|
38
|
+
* ICU validates code membership; explicitly reject reserved pseudo-regions.
|
|
39
|
+
*/
|
|
40
|
+
export function normalizeHreflangLocale(raw) {
|
|
41
|
+
if (!raw || raw.length > 32)
|
|
42
|
+
return undefined;
|
|
43
|
+
if (raw.toLowerCase() === "x-default")
|
|
44
|
+
return "x-default";
|
|
45
|
+
const match = /^([a-z]{2})(?:-([a-z]{4}))?(?:-([a-z]{2}))?$/i.exec(raw);
|
|
46
|
+
if (!match)
|
|
47
|
+
return undefined;
|
|
48
|
+
const language = match[1].toLowerCase();
|
|
49
|
+
const script = match[2];
|
|
50
|
+
const region = match[3]?.toUpperCase();
|
|
51
|
+
const scriptCode = script ? script.slice(0, 1).toUpperCase() + script.slice(1).toLowerCase() : "";
|
|
52
|
+
if (!languages.of(language) || (scriptCode && !scripts.of(scriptCode)) ||
|
|
53
|
+
(region && (REGION_CODES_RESERVED.has(region) || !regions.of(region)))) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return language + (scriptCode ? "-" + scriptCode : "") + (region ? "-" + region : "");
|
|
57
|
+
}
|
|
58
|
+
function relationIncludes(raw, token) {
|
|
59
|
+
return (raw ?? "").toLowerCase().split(/[\t\r\n\f ]+/).includes(token);
|
|
60
|
+
}
|
|
61
|
+
function documentLanguage(raw) {
|
|
62
|
+
if (!raw)
|
|
63
|
+
return undefined;
|
|
64
|
+
try {
|
|
65
|
+
const locale = new Intl.Locale(raw);
|
|
66
|
+
if (!/^[a-z]{2}$/.test(locale.language))
|
|
67
|
+
return undefined;
|
|
68
|
+
return locale.language +
|
|
69
|
+
(locale.script ? "-" + locale.script.toLowerCase() : "");
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function expectedLanguage(reference) {
|
|
76
|
+
const parts = reference.split("-");
|
|
77
|
+
return parts[0] +
|
|
78
|
+
(parts.length > 1 && parts[1].length === 4 ? "-" + parts[1].toLowerCase() : "");
|
|
79
|
+
}
|
|
80
|
+
function emptyPage(url) {
|
|
81
|
+
return {
|
|
82
|
+
url, canonical_state: "missing", references: [], invalid_declarations: 0,
|
|
83
|
+
repeated_locales: 0, conflicting_locales: 0,
|
|
84
|
+
declarations_truncated: false, skipped: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Pure, runtime-independent validation of head-only HTML observations. */
|
|
88
|
+
export function analyzeMultilingualHtmlSignals({ rawUrl, htmlLength, rawLanguage, links, }) {
|
|
89
|
+
const url = safeMultilingualUrl(rawUrl);
|
|
90
|
+
if (!url || htmlLength > MAX_MULTILINGUAL_HTML_CHARS || htmlLength < 1) {
|
|
91
|
+
return emptyPage(url ?? "");
|
|
92
|
+
}
|
|
93
|
+
const language = documentLanguage(rawLanguage?.trim());
|
|
94
|
+
const canonicalLinks = links.filter((link) => relationIncludes(link.rel, "canonical"));
|
|
95
|
+
let canonicalState = "missing";
|
|
96
|
+
let canonicalUrl;
|
|
97
|
+
if (canonicalLinks.length > 1)
|
|
98
|
+
canonicalState = "ambiguous";
|
|
99
|
+
else if (canonicalLinks.length === 1) {
|
|
100
|
+
const link = canonicalLinks[0];
|
|
101
|
+
const hasAnnotations = link.hreflang !== undefined || link.hasMedia || link.hasType || link.hasLang;
|
|
102
|
+
canonicalUrl = hasAnnotations ? undefined : safeMultilingualUrl(link.href?.trim() ?? "");
|
|
103
|
+
canonicalState = canonicalUrl ? "usable" : "unverifiable";
|
|
104
|
+
}
|
|
105
|
+
const refs = [];
|
|
106
|
+
const indexed = new Map();
|
|
107
|
+
let invalid = 0;
|
|
108
|
+
let repeated = 0;
|
|
109
|
+
let conflicting = 0;
|
|
110
|
+
let overflow = false;
|
|
111
|
+
const declarations = links.filter((link) => link.hreflang !== undefined);
|
|
112
|
+
if (declarations.length > MAX_HREFLANG_DECLARATIONS_SCANNED)
|
|
113
|
+
overflow = true;
|
|
114
|
+
for (const link of declarations.slice(0, MAX_HREFLANG_DECLARATIONS_SCANNED)) {
|
|
115
|
+
const locale = normalizeHreflangLocale(link.hreflang?.trim() ?? "");
|
|
116
|
+
const target = safeMultilingualUrl(link.href?.trim() ?? "");
|
|
117
|
+
// Media/type annotations on the same link are not supported by Google.
|
|
118
|
+
if (!relationIncludes(link.rel, "alternate") ||
|
|
119
|
+
link.hasMedia || link.hasType ||
|
|
120
|
+
!locale || !target) {
|
|
121
|
+
invalid += 1;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const existing = indexed.get(locale);
|
|
125
|
+
if (existing !== undefined) {
|
|
126
|
+
if (existing === target)
|
|
127
|
+
repeated += 1;
|
|
128
|
+
else
|
|
129
|
+
conflicting += 1;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const localeCount = indexed.has("x-default") ? indexed.size - 1 : indexed.size;
|
|
133
|
+
if (locale !== "x-default" && localeCount >= MAX_HREFLANG_LOCALES) {
|
|
134
|
+
overflow = true;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
indexed.set(locale, target);
|
|
138
|
+
refs.push({ locale, url: target });
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
url,
|
|
142
|
+
...(language ? { language } : {}),
|
|
143
|
+
canonical_state: canonicalState,
|
|
144
|
+
...(canonicalUrl ? { canonical_url: canonicalUrl } : {}),
|
|
145
|
+
references: refs,
|
|
146
|
+
invalid_declarations: invalid,
|
|
147
|
+
repeated_locales: repeated,
|
|
148
|
+
conflicting_locales: conflicting,
|
|
149
|
+
declarations_truncated: overflow,
|
|
150
|
+
skipped: false,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function findingOrder(finding) {
|
|
154
|
+
return finding.severity === "error" ? 0 : 1;
|
|
155
|
+
}
|
|
156
|
+
function compareFindings(left, right) {
|
|
157
|
+
return findingOrder(left) - findingOrder(right)
|
|
158
|
+
|| left.code.localeCompare(right.code)
|
|
159
|
+
|| (left.example_urls[0] ?? "").localeCompare(right.example_urls[0] ?? "");
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check at most 16 supplied pages. Missing unsampled targets are unknown,
|
|
163
|
+
* not broken; the sample can include HTML from multiple authorized origins.
|
|
164
|
+
*/
|
|
165
|
+
export function analyzeMultilingualClusters(observations, options = {}) {
|
|
166
|
+
if (observations.length > MAX_MULTILINGUAL_PAGES) {
|
|
167
|
+
throw new Error("Multilingual cluster analysis accepts at most 16 pages.");
|
|
168
|
+
}
|
|
169
|
+
const sampledPages = options.sampledPages ?? observations.length;
|
|
170
|
+
if (!Number.isSafeInteger(sampledPages) ||
|
|
171
|
+
sampledPages < observations.length || sampledPages > MAX_MULTILINGUAL_PAGES) {
|
|
172
|
+
throw new Error("sampledPages must be between observed count and sixteen.");
|
|
173
|
+
}
|
|
174
|
+
const byUrl = new Map();
|
|
175
|
+
for (const observation of observations) {
|
|
176
|
+
const url = safeMultilingualUrl(observation.url);
|
|
177
|
+
if (!observation.skipped && url && !byUrl.has(url))
|
|
178
|
+
byUrl.set(url, observation);
|
|
179
|
+
}
|
|
180
|
+
const pages = [...byUrl.values()];
|
|
181
|
+
const findings = [];
|
|
182
|
+
const seen = new Set();
|
|
183
|
+
let totalFindings = 0;
|
|
184
|
+
function report(code, severity, confidence, message, urls) {
|
|
185
|
+
const examples = [...new Set(urls)].filter((url) => Boolean(safeMultilingualUrl(url)))
|
|
186
|
+
.slice(0, MAX_EXAMPLE_URLS);
|
|
187
|
+
const key = JSON.stringify([code, examples]);
|
|
188
|
+
if (seen.has(key))
|
|
189
|
+
return;
|
|
190
|
+
seen.add(key);
|
|
191
|
+
totalFindings += 1;
|
|
192
|
+
const next = { code, severity, confidence, message, example_urls: examples };
|
|
193
|
+
if (findings.length < MAX_MULTILINGUAL_FINDINGS) {
|
|
194
|
+
findings.push(next);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
// Bounded top-k selection: late high-priority errors must still displace
|
|
198
|
+
// earlier warnings while preserving the full finding count.
|
|
199
|
+
let worst = 0;
|
|
200
|
+
for (let i = 1; i < findings.length; i += 1) {
|
|
201
|
+
if (compareFindings(findings[i], findings[worst]) > 0)
|
|
202
|
+
worst = i;
|
|
203
|
+
}
|
|
204
|
+
if (compareFindings(next, findings[worst]) < 0)
|
|
205
|
+
findings[worst] = next;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const allLocales = new Set();
|
|
209
|
+
const unseen = new Set();
|
|
210
|
+
let invalid = 0;
|
|
211
|
+
let incomplete = sampledPages !== pages.length || Boolean(options.coverageLimited);
|
|
212
|
+
for (const page of pages) {
|
|
213
|
+
invalid += page.invalid_declarations;
|
|
214
|
+
if (page.invalid_declarations > 0) {
|
|
215
|
+
incomplete = true;
|
|
216
|
+
report("multilingual.unusable_declaration", "warning", "observed", "A sampled page has hreflang declarations with invalid codes, targets or link attributes; they were excluded from comparison.", [page.url]);
|
|
217
|
+
}
|
|
218
|
+
if (page.declarations_truncated) {
|
|
219
|
+
incomplete = true;
|
|
220
|
+
report("multilingual.locale_limit", "warning", "observed", "A sampled page exceeds the supported 16 locale references (plus x-default) or the bounded declaration scan; cluster checks are incomplete.", [page.url]);
|
|
221
|
+
}
|
|
222
|
+
if (page.conflicting_locales > 0) {
|
|
223
|
+
incomplete = true;
|
|
224
|
+
report("multilingual.locale_conflict", "error", "observed", "A sampled page assigns more than one target URL to the same hreflang locale.", [page.url]);
|
|
225
|
+
}
|
|
226
|
+
if (page.repeated_locales > 0) {
|
|
227
|
+
report("multilingual.repeated_locale", "warning", "observed", "A sampled page repeats an identical hreflang locale/URL declaration.", [page.url]);
|
|
228
|
+
}
|
|
229
|
+
if (page.references.length > 0 && (page.canonical_state === "ambiguous" ||
|
|
230
|
+
page.canonical_state === "unverifiable")) {
|
|
231
|
+
incomplete = true;
|
|
232
|
+
report("multilingual.canonical_ambiguous", "warning", "observed", "A multilingual page has ambiguous or unusable canonical declarations.", [page.url]);
|
|
233
|
+
}
|
|
234
|
+
const hasLocales = page.references.some((ref) => ref.locale !== "x-default");
|
|
235
|
+
if (hasLocales && !page.references.some((ref) => ref.url === page.url && ref.locale !== "x-default")) {
|
|
236
|
+
report("multilingual.self_reference_missing", "warning", "observed", "A sampled multilingual page does not include itself among its hreflang alternate URLs.", [page.url]);
|
|
237
|
+
}
|
|
238
|
+
if (hasLocales && page.canonical_state === "usable" && page.canonical_url !== page.url) {
|
|
239
|
+
report("multilingual.non_self_canonical", "warning", "potential", "A sampled multilingual page declares a different canonical URL; verify that hreflang targets point to canonical localized pages.", [page.url, page.canonical_url ?? ""]);
|
|
240
|
+
}
|
|
241
|
+
for (const ref of page.references) {
|
|
242
|
+
if (ref.locale !== "x-default")
|
|
243
|
+
allLocales.add(ref.locale);
|
|
244
|
+
const target = byUrl.get(ref.url);
|
|
245
|
+
if (!target) {
|
|
246
|
+
unseen.add(ref.url);
|
|
247
|
+
incomplete = true;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (target.canonical_state === "usable" && target.canonical_url !== target.url) {
|
|
251
|
+
report("multilingual.target_not_canonical", "warning", "observed", "A sampled hreflang target declares a different canonical; check the localized canonical cluster.", [page.url, target.url]);
|
|
252
|
+
}
|
|
253
|
+
// x-default names a fallback page, not a localized reciprocal.
|
|
254
|
+
// It cannot by itself satisfy a missing localized return reference.
|
|
255
|
+
if (target.url !== page.url && !target.references.some((back) => back.locale !== "x-default" && back.url === page.url)) {
|
|
256
|
+
report("multilingual.return_link_missing", "warning", "observed", "A sampled alternate target does not link back to the referring page.", [page.url, target.url]);
|
|
257
|
+
}
|
|
258
|
+
if (ref.locale !== "x-default" && target.language &&
|
|
259
|
+
expectedLanguage(ref.locale) !== target.language) {
|
|
260
|
+
report("multilingual.language_signal_mismatch", "warning", "potential", "A sampled hreflang locale disagrees with the target document's HTML language/script signal; check the intended audience and actual page language.", [page.url, target.url]);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// Already known sampled pages that lack alternates do not prove that any
|
|
264
|
+
// unsampled alternate pages are missing return links.
|
|
265
|
+
}
|
|
266
|
+
if (allLocales.size > MAX_HREFLANG_LOCALES) {
|
|
267
|
+
incomplete = true;
|
|
268
|
+
report("multilingual.cross_page_locale_limit", "warning", "potential", "The compared pages collectively advertise more than 16 distinct locale variants; this bounded cluster review cannot certify all variants.", pages.map((p) => p.url));
|
|
269
|
+
}
|
|
270
|
+
// Diagnose canonical cycles and chains only when every intermediate target
|
|
271
|
+
// was actually supplied. Never treat an unseen canonical as broken.
|
|
272
|
+
const canonicalCycles = new Set();
|
|
273
|
+
for (const page of pages) {
|
|
274
|
+
if (page.canonical_state !== "usable" || !page.canonical_url || page.canonical_url === page.url)
|
|
275
|
+
continue;
|
|
276
|
+
const target = byUrl.get(page.canonical_url);
|
|
277
|
+
if (!target || target.canonical_state !== "usable" || !target.canonical_url)
|
|
278
|
+
continue;
|
|
279
|
+
if (target.canonical_url === page.url) {
|
|
280
|
+
const urls = [page.url, target.url].sort();
|
|
281
|
+
const key = JSON.stringify(urls);
|
|
282
|
+
if (!canonicalCycles.has(key)) {
|
|
283
|
+
canonicalCycles.add(key);
|
|
284
|
+
report("multilingual.canonical_cycle", "error", "observed", "Two sampled localized pages point their canonical declarations at one another.", urls);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else if (target.canonical_url !== target.url && byUrl.has(target.canonical_url)) {
|
|
288
|
+
report("multilingual.canonical_chain", "warning", "potential", "A sampled localized page canonicals to a sampled page which itself canonicals elsewhere.", [page.url, target.url]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// Undirected edges only among sampled, explicitly linked pages; completely
|
|
292
|
+
// unrelated page families must not be forced into one hreflang cluster.
|
|
293
|
+
const visited = new Set();
|
|
294
|
+
for (const start of pages) {
|
|
295
|
+
if (visited.has(start.url) || start.references.length === 0)
|
|
296
|
+
continue;
|
|
297
|
+
const component = [];
|
|
298
|
+
const queue = [start.url];
|
|
299
|
+
while (queue.length > 0) {
|
|
300
|
+
const current = queue.pop();
|
|
301
|
+
if (visited.has(current))
|
|
302
|
+
continue;
|
|
303
|
+
visited.add(current);
|
|
304
|
+
const page = byUrl.get(current);
|
|
305
|
+
if (!page)
|
|
306
|
+
continue;
|
|
307
|
+
component.push(page);
|
|
308
|
+
for (const ref of page.references) {
|
|
309
|
+
if (ref.url !== page.url && byUrl.has(ref.url) && !visited.has(ref.url))
|
|
310
|
+
queue.push(ref.url);
|
|
311
|
+
}
|
|
312
|
+
for (const candidate of pages) {
|
|
313
|
+
if (candidate.references.some((ref) => ref.url === current) && !visited.has(candidate.url)) {
|
|
314
|
+
queue.push(candidate.url);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (component.length < 2)
|
|
319
|
+
continue;
|
|
320
|
+
const expected = new Map();
|
|
321
|
+
for (const page of component) {
|
|
322
|
+
for (const ref of page.references) {
|
|
323
|
+
const previous = expected.get(ref.locale);
|
|
324
|
+
if (!previous)
|
|
325
|
+
expected.set(ref.locale, { target: ref.url, page: page.url });
|
|
326
|
+
else if (previous.target !== ref.url) {
|
|
327
|
+
report("multilingual.cluster_target_conflict", "error", "observed", "Linked sampled pages disagree on the target URL for the same hreflang locale.", [previous.page, page.url]);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (const page of component) {
|
|
332
|
+
const locales = new Set(page.references.map((ref) => ref.locale));
|
|
333
|
+
if ([...expected.keys()].some((code) => !locales.has(code))) {
|
|
334
|
+
report("multilingual.cluster_incomplete", "warning", "potential", "A sampled page omits one or more locales advertised by a linked sampled page; verify reciprocal links for each intended variant.", [page.url]);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
findings.sort(compareFindings);
|
|
339
|
+
const skipped = sampledPages - pages.length;
|
|
340
|
+
const limitations = [
|
|
341
|
+
"Only already supplied or sampled static HTML is checked; unsampled pages and HTTP-header/sitemap hreflang annotations are not verified.",
|
|
342
|
+
"Hreflang, HTML lang and canonical declarations do not prove Google's selected canonical, detected page language, indexing or rankings.",
|
|
343
|
+
...(skipped ? [String(skipped) + " page(s) were missing, invalid, oversized or duplicated in the comparison input."] : []),
|
|
344
|
+
...(unseen.size || options.coverageLimited
|
|
345
|
+
? ["Referenced targets outside the page sample remain unverified; rerun with additional authorized page HTML."] : []),
|
|
346
|
+
];
|
|
347
|
+
return {
|
|
348
|
+
scope: "sampled_pages_only",
|
|
349
|
+
sampled_pages: sampledPages,
|
|
350
|
+
eligible_pages: pages.length,
|
|
351
|
+
pages_with_alternates: pages.filter((page) => page.references.length > 0).length,
|
|
352
|
+
locales_observed: allLocales.size,
|
|
353
|
+
unobserved_targets: unseen.size,
|
|
354
|
+
invalid_declarations: invalid,
|
|
355
|
+
coverage_limited: incomplete || sampledPages < 2 ||
|
|
356
|
+
pages.filter((page) => page.references.length > 0).length < 2,
|
|
357
|
+
limitations,
|
|
358
|
+
total_findings: totalFindings,
|
|
359
|
+
findings,
|
|
360
|
+
findings_truncated: totalFindings > MAX_MULTILINGUAL_FINDINGS,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=multilingual-clusters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multilingual-clusters.js","sourceRoot":"","sources":["../../../src/modules/site-architecture/multilingual-clusters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MA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CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;QAC/D,WAAW;QACX,cAAc,EAAE,aAAa;QAC7B,QAAQ;QACR,kBAAkB,EAAE,aAAa,GAAG,yBAAyB;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * P1-02: bounded hreflang and canonical cluster verification.\n *\n * Pure local/Worker logic over explicitly supplied static HTML observations.\n * Never fetch a referenced URL, infer Google's canonical choice, or echo\n * credentialed/query-bearing links.\n */\nexport const MAX_MULTILINGUAL_PAGES = 16;\nexport const MAX_HREFLANG_LOCALES = 16;\nexport const MAX_HREFLANG_DECLARATIONS_SCANNED = 64;\nexport const MAX_MULTILINGUAL_FINDINGS = 12;\nconst MAX_PUBLIC_LABEL_CHARS = 256;\nexport const MAX_MULTILINGUAL_HTML_CHARS = 250_000;\nconst MAX_EXAMPLE_URLS = 2;\n\nexport interface MultilingualReference {\n locale: string;\n url: string;\n}\n\nexport interface MultilingualHtmlLink {\n rel?: string;\n href?: string;\n hreflang?: string;\n hasMedia?: boolean;\n hasType?: boolean;\n hasLang?: boolean;\n}\n\nexport interface ParsedMultilingualHtml {\n rawUrl: string;\n htmlLength: number;\n rawLanguage?: string;\n links: MultilingualHtmlLink[];\n}\n\nexport type MultilingualCanonicalState = \"missing\" | \"usable\" | \"ambiguous\" | \"unverifiable\";\n\nexport interface MultilingualPageObservation {\n url: string;\n language?: string;\n canonical_state: MultilingualCanonicalState;\n canonical_url?: string;\n references: MultilingualReference[];\n invalid_declarations: number;\n repeated_locales: number;\n conflicting_locales: number;\n declarations_truncated: boolean;\n skipped: boolean;\n}\n\nexport interface MultilingualFinding {\n code: string;\n severity: \"error\" | \"warning\";\n confidence: \"observed\" | \"potential\";\n message: string;\n example_urls: string[];\n}\n\nexport interface MultilingualClusterAnalysis {\n scope: \"sampled_pages_only\";\n sampled_pages: number;\n eligible_pages: number;\n pages_with_alternates: number;\n locales_observed: number;\n unobserved_targets: number;\n invalid_declarations: number;\n coverage_limited: boolean;\n limitations: string[];\n total_findings: number;\n findings: MultilingualFinding[];\n findings_truncated: boolean;\n}\n\nconst REGION_CODES_RESERVED = new Set([\"EU\", \"UN\", \"UK\", \"ZZ\"]);\nconst regions = new Intl.DisplayNames([\"en\"], { type: \"region\", fallback: \"none\" });\nconst languages = new Intl.DisplayNames([\"en\"], { type: \"language\", fallback: \"none\" });\nconst scripts = new Intl.DisplayNames([\"en\"], { type: \"script\", fallback: \"none\" });\n\n/** Deliberately require absolute, query-free references rather than masking changes in targets. */\nexport function safeMultilingualUrl(raw: string): string | undefined {\n if (raw.length === 0 || raw.length > MAX_PUBLIC_LABEL_CHARS) return undefined;\n try {\n const url = new URL(raw);\n if ((url.protocol !== \"https:\" && url.protocol !== \"http:\") ||\n !url.hostname || url.username || url.password || url.search || url.hash || url.port) {\n return undefined;\n }\n return url.href;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Accept Google's documented HTML hreflang forms: ISO 639-1 language, optional\n * ISO 15924 script, optional ISO 3166-1 alpha-2 region, and x-default.\n * ICU validates code membership; explicitly reject reserved pseudo-regions.\n */\nexport function normalizeHreflangLocale(raw: string): string | undefined {\n if (!raw || raw.length > 32) return undefined;\n if (raw.toLowerCase() === \"x-default\") return \"x-default\";\n const match = /^([a-z]{2})(?:-([a-z]{4}))?(?:-([a-z]{2}))?$/i.exec(raw);\n if (!match) return undefined;\n const language = match[1].toLowerCase();\n const script = match[2];\n const region = match[3]?.toUpperCase();\n const scriptCode = script ? script.slice(0, 1).toUpperCase() + script.slice(1).toLowerCase() : \"\";\n if (!languages.of(language) || (scriptCode && !scripts.of(scriptCode)) ||\n (region && (REGION_CODES_RESERVED.has(region) || !regions.of(region)))) {\n return undefined;\n }\n return language + (scriptCode ? \"-\" + scriptCode : \"\") + (region ? \"-\" + region : \"\");\n}\n\nfunction relationIncludes(raw: string | undefined, token: string): boolean {\n return (raw ?? \"\").toLowerCase().split(/[\\t\\r\\n\\f ]+/).includes(token);\n}\n\nfunction documentLanguage(raw: string | undefined): string | undefined {\n if (!raw) return undefined;\n try {\n const locale = new Intl.Locale(raw);\n if (!/^[a-z]{2}$/.test(locale.language)) return undefined;\n return locale.language +\n (locale.script ? \"-\" + locale.script.toLowerCase() : \"\");\n } catch {\n return undefined;\n }\n}\n\nfunction expectedLanguage(reference: string): string {\n const parts = reference.split(\"-\");\n return parts[0] +\n (parts.length > 1 && parts[1].length === 4 ? \"-\" + parts[1].toLowerCase() : \"\");\n}\n\nfunction emptyPage(url: string): MultilingualPageObservation {\n return {\n url, canonical_state: \"missing\", references: [], invalid_declarations: 0,\n repeated_locales: 0, conflicting_locales: 0,\n declarations_truncated: false, skipped: true,\n };\n}\n\n/** Pure, runtime-independent validation of head-only HTML observations. */\nexport function analyzeMultilingualHtmlSignals({\n rawUrl, htmlLength, rawLanguage, links,\n}: ParsedMultilingualHtml): MultilingualPageObservation {\n const url = safeMultilingualUrl(rawUrl);\n if (!url || htmlLength > MAX_MULTILINGUAL_HTML_CHARS || htmlLength < 1) {\n return emptyPage(url ?? \"\");\n }\n const language = documentLanguage(rawLanguage?.trim());\n const canonicalLinks = links.filter((link) => relationIncludes(link.rel, \"canonical\"));\n let canonicalState: MultilingualCanonicalState = \"missing\";\n let canonicalUrl: string | undefined;\n if (canonicalLinks.length > 1) canonicalState = \"ambiguous\";\n else if (canonicalLinks.length === 1) {\n const link = canonicalLinks[0];\n const hasAnnotations = link.hreflang !== undefined || link.hasMedia || link.hasType || link.hasLang;\n canonicalUrl = hasAnnotations ? undefined : safeMultilingualUrl(link.href?.trim() ?? \"\");\n canonicalState = canonicalUrl ? \"usable\" : \"unverifiable\";\n }\n\n const refs: MultilingualReference[] = [];\n const indexed = new Map<string, string>();\n let invalid = 0;\n let repeated = 0;\n let conflicting = 0;\n let overflow = false;\n const declarations = links.filter((link) => link.hreflang !== undefined);\n if (declarations.length > MAX_HREFLANG_DECLARATIONS_SCANNED) overflow = true;\n for (const link of declarations.slice(0, MAX_HREFLANG_DECLARATIONS_SCANNED)) {\n const locale = normalizeHreflangLocale(link.hreflang?.trim() ?? \"\");\n const target = safeMultilingualUrl(link.href?.trim() ?? \"\");\n // Media/type annotations on the same link are not supported by Google.\n if (!relationIncludes(link.rel, \"alternate\") ||\n link.hasMedia || link.hasType ||\n !locale || !target) {\n invalid += 1;\n continue;\n }\n const existing = indexed.get(locale);\n if (existing !== undefined) {\n if (existing === target) repeated += 1;\n else conflicting += 1;\n continue;\n }\n const localeCount = indexed.has(\"x-default\") ? indexed.size - 1 : indexed.size;\n if (locale !== \"x-default\" && localeCount >= MAX_HREFLANG_LOCALES) {\n overflow = true;\n continue;\n }\n indexed.set(locale, target);\n refs.push({ locale, url: target });\n }\n return {\n url,\n ...(language ? { language } : {}),\n canonical_state: canonicalState,\n ...(canonicalUrl ? { canonical_url: canonicalUrl } : {}),\n references: refs,\n invalid_declarations: invalid,\n repeated_locales: repeated,\n conflicting_locales: conflicting,\n declarations_truncated: overflow,\n skipped: false,\n };\n}\n\nfunction findingOrder(finding: MultilingualFinding): number {\n return finding.severity === \"error\" ? 0 : 1;\n}\n\nfunction compareFindings(left: MultilingualFinding, right: MultilingualFinding): number {\n return findingOrder(left) - findingOrder(right)\n || left.code.localeCompare(right.code)\n || (left.example_urls[0] ?? \"\").localeCompare(right.example_urls[0] ?? \"\");\n}\n\n/**\n * Check at most 16 supplied pages. Missing unsampled targets are unknown,\n * not broken; the sample can include HTML from multiple authorized origins.\n */\nexport function analyzeMultilingualClusters(\n observations: readonly MultilingualPageObservation[],\n options: { sampledPages?: number; coverageLimited?: boolean } = {},\n): MultilingualClusterAnalysis {\n if (observations.length > MAX_MULTILINGUAL_PAGES) {\n throw new Error(\"Multilingual cluster analysis accepts at most 16 pages.\");\n }\n const sampledPages = options.sampledPages ?? observations.length;\n if (!Number.isSafeInteger(sampledPages) ||\n sampledPages < observations.length || sampledPages > MAX_MULTILINGUAL_PAGES) {\n throw new Error(\"sampledPages must be between observed count and sixteen.\");\n }\n const byUrl = new Map<string, MultilingualPageObservation>();\n for (const observation of observations) {\n const url = safeMultilingualUrl(observation.url);\n if (!observation.skipped && url && !byUrl.has(url)) byUrl.set(url, observation);\n }\n const pages = [...byUrl.values()];\n const findings: MultilingualFinding[] = [];\n const seen = new Set<string>();\n let totalFindings = 0;\n function report(code: string, severity: MultilingualFinding[\"severity\"],\n confidence: MultilingualFinding[\"confidence\"], message: string, urls: string[]) {\n const examples = [...new Set(urls)].filter((url) => Boolean(safeMultilingualUrl(url)))\n .slice(0, MAX_EXAMPLE_URLS);\n const key = JSON.stringify([code, examples]);\n if (seen.has(key)) return;\n seen.add(key);\n totalFindings += 1;\n const next: MultilingualFinding = { code, severity, confidence, message, example_urls: examples };\n if (findings.length < MAX_MULTILINGUAL_FINDINGS) {\n findings.push(next);\n } else {\n // Bounded top-k selection: late high-priority errors must still displace\n // earlier warnings while preserving the full finding count.\n let worst = 0;\n for (let i = 1; i < findings.length; i += 1) {\n if (compareFindings(findings[i], findings[worst]) > 0) worst = i;\n }\n if (compareFindings(next, findings[worst]) < 0) findings[worst] = next;\n }\n }\n const allLocales = new Set<string>();\n const unseen = new Set<string>();\n let invalid = 0;\n let incomplete = sampledPages !== pages.length || Boolean(options.coverageLimited);\n for (const page of pages) {\n invalid += page.invalid_declarations;\n if (page.invalid_declarations > 0) {\n incomplete = true;\n report(\"multilingual.unusable_declaration\", \"warning\", \"observed\",\n \"A sampled page has hreflang declarations with invalid codes, targets or link attributes; they were excluded from comparison.\",\n [page.url]);\n }\n if (page.declarations_truncated) {\n incomplete = true;\n report(\"multilingual.locale_limit\", \"warning\", \"observed\",\n \"A sampled page exceeds the supported 16 locale references (plus x-default) or the bounded declaration scan; cluster checks are incomplete.\",\n [page.url]);\n }\n if (page.conflicting_locales > 0) {\n incomplete = true;\n report(\"multilingual.locale_conflict\", \"error\", \"observed\",\n \"A sampled page assigns more than one target URL to the same hreflang locale.\",\n [page.url]);\n }\n if (page.repeated_locales > 0) {\n report(\"multilingual.repeated_locale\", \"warning\", \"observed\",\n \"A sampled page repeats an identical hreflang locale/URL declaration.\",\n [page.url]);\n }\n if (page.references.length > 0 && (page.canonical_state === \"ambiguous\" ||\n page.canonical_state === \"unverifiable\")) {\n incomplete = true;\n report(\"multilingual.canonical_ambiguous\", \"warning\", \"observed\",\n \"A multilingual page has ambiguous or unusable canonical declarations.\",\n [page.url]);\n }\n const hasLocales = page.references.some((ref) => ref.locale !== \"x-default\");\n if (hasLocales && !page.references.some((ref) => ref.url === page.url && ref.locale !== \"x-default\")) {\n report(\"multilingual.self_reference_missing\", \"warning\", \"observed\",\n \"A sampled multilingual page does not include itself among its hreflang alternate URLs.\",\n [page.url]);\n }\n if (hasLocales && page.canonical_state === \"usable\" && page.canonical_url !== page.url) {\n report(\"multilingual.non_self_canonical\", \"warning\", \"potential\",\n \"A sampled multilingual page declares a different canonical URL; verify that hreflang targets point to canonical localized pages.\",\n [page.url, page.canonical_url ?? \"\"]);\n }\n for (const ref of page.references) {\n if (ref.locale !== \"x-default\") allLocales.add(ref.locale);\n const target = byUrl.get(ref.url);\n if (!target) {\n unseen.add(ref.url);\n incomplete = true;\n continue;\n }\n if (target.canonical_state === \"usable\" && target.canonical_url !== target.url) {\n report(\"multilingual.target_not_canonical\", \"warning\", \"observed\",\n \"A sampled hreflang target declares a different canonical; check the localized canonical cluster.\",\n [page.url, target.url]);\n }\n // x-default names a fallback page, not a localized reciprocal.\n // It cannot by itself satisfy a missing localized return reference.\n if (target.url !== page.url && !target.references.some((back) =>\n back.locale !== \"x-default\" && back.url === page.url)) {\n report(\"multilingual.return_link_missing\", \"warning\", \"observed\",\n \"A sampled alternate target does not link back to the referring page.\",\n [page.url, target.url]);\n }\n if (ref.locale !== \"x-default\" && target.language &&\n expectedLanguage(ref.locale) !== target.language) {\n report(\"multilingual.language_signal_mismatch\", \"warning\", \"potential\",\n \"A sampled hreflang locale disagrees with the target document's HTML language/script signal; check the intended audience and actual page language.\",\n [page.url, target.url]);\n }\n }\n // Already known sampled pages that lack alternates do not prove that any\n // unsampled alternate pages are missing return links.\n }\n if (allLocales.size > MAX_HREFLANG_LOCALES) {\n incomplete = true;\n report(\"multilingual.cross_page_locale_limit\", \"warning\", \"potential\",\n \"The compared pages collectively advertise more than 16 distinct locale variants; this bounded cluster review cannot certify all variants.\",\n pages.map((p) => p.url));\n }\n\n // Diagnose canonical cycles and chains only when every intermediate target\n // was actually supplied. Never treat an unseen canonical as broken.\n const canonicalCycles = new Set<string>();\n for (const page of pages) {\n if (page.canonical_state !== \"usable\" || !page.canonical_url || page.canonical_url === page.url) continue;\n const target = byUrl.get(page.canonical_url);\n if (!target || target.canonical_state !== \"usable\" || !target.canonical_url) continue;\n if (target.canonical_url === page.url) {\n const urls = [page.url, target.url].sort();\n const key = JSON.stringify(urls);\n if (!canonicalCycles.has(key)) {\n canonicalCycles.add(key);\n report(\"multilingual.canonical_cycle\", \"error\", \"observed\",\n \"Two sampled localized pages point their canonical declarations at one another.\",\n urls);\n }\n } else if (target.canonical_url !== target.url && byUrl.has(target.canonical_url)) {\n report(\"multilingual.canonical_chain\", \"warning\", \"potential\",\n \"A sampled localized page canonicals to a sampled page which itself canonicals elsewhere.\",\n [page.url, target.url]);\n }\n }\n\n // Undirected edges only among sampled, explicitly linked pages; completely\n // unrelated page families must not be forced into one hreflang cluster.\n const visited = new Set<string>();\n for (const start of pages) {\n if (visited.has(start.url) || start.references.length === 0) continue;\n const component: MultilingualPageObservation[] = [];\n const queue = [start.url];\n while (queue.length > 0) {\n const current = queue.pop()!;\n if (visited.has(current)) continue;\n visited.add(current);\n const page = byUrl.get(current);\n if (!page) continue;\n component.push(page);\n for (const ref of page.references) {\n if (ref.url !== page.url && byUrl.has(ref.url) && !visited.has(ref.url)) queue.push(ref.url);\n }\n for (const candidate of pages) {\n if (candidate.references.some((ref) => ref.url === current) && !visited.has(candidate.url)) {\n queue.push(candidate.url);\n }\n }\n }\n if (component.length < 2) continue;\n const expected = new Map<string, { target: string; page: string }>();\n for (const page of component) {\n for (const ref of page.references) {\n const previous = expected.get(ref.locale);\n if (!previous) expected.set(ref.locale, { target: ref.url, page: page.url });\n else if (previous.target !== ref.url) {\n report(\"multilingual.cluster_target_conflict\", \"error\", \"observed\",\n \"Linked sampled pages disagree on the target URL for the same hreflang locale.\",\n [previous.page, page.url]);\n }\n }\n }\n for (const page of component) {\n const locales = new Set(page.references.map((ref) => ref.locale));\n if ([...expected.keys()].some((code) => !locales.has(code))) {\n report(\"multilingual.cluster_incomplete\", \"warning\", \"potential\",\n \"A sampled page omits one or more locales advertised by a linked sampled page; verify reciprocal links for each intended variant.\",\n [page.url]);\n }\n }\n }\n\n findings.sort(compareFindings);\n const skipped = sampledPages - pages.length;\n const limitations = [\n \"Only already supplied or sampled static HTML is checked; unsampled pages and HTTP-header/sitemap hreflang annotations are not verified.\",\n \"Hreflang, HTML lang and canonical declarations do not prove Google's selected canonical, detected page language, indexing or rankings.\",\n ...(skipped ? [String(skipped) + \" page(s) were missing, invalid, oversized or duplicated in the comparison input.\"] : []),\n ...(unseen.size || options.coverageLimited\n ? [\"Referenced targets outside the page sample remain unverified; rerun with additional authorized page HTML.\"] : []),\n ];\n return {\n scope: \"sampled_pages_only\",\n sampled_pages: sampledPages,\n eligible_pages: pages.length,\n pages_with_alternates: pages.filter((page) => page.references.length > 0).length,\n locales_observed: allLocales.size,\n unobserved_targets: unseen.size,\n invalid_declarations: invalid,\n coverage_limited: incomplete || sampledPages < 2 ||\n pages.filter((page) => page.references.length > 0).length < 2,\n limitations,\n total_findings: totalFindings,\n findings,\n findings_truncated: totalFindings > MAX_MULTILINGUAL_FINDINGS,\n };\n}\n"]}
|
package/dist/network.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export interface PublicFetchOptions {
|
|
|
3
3
|
headers?: Record<string, string>;
|
|
4
4
|
timeoutMs?: number;
|
|
5
5
|
maxRedirects?: number;
|
|
6
|
+
/** Observe each response before redirect handling; no body is consumed. */
|
|
7
|
+
onResponse?: (url: URL, response: Response) => void;
|
|
8
|
+
/** Optional per-redirect scope guard; returning false leaves the 3xx response intact. */
|
|
9
|
+
allowRedirect?: (nextUrl: URL, currentUrl: URL) => boolean;
|
|
6
10
|
}
|
|
7
11
|
export interface PublicTextOptions extends PublicFetchOptions {
|
|
8
12
|
maxBytes?: number;
|
package/dist/network.js
CHANGED
|
@@ -528,6 +528,14 @@ export async function fetchPublicHttp(input, options = {}) {
|
|
|
528
528
|
await dispatcher.close();
|
|
529
529
|
throw error;
|
|
530
530
|
}
|
|
531
|
+
try {
|
|
532
|
+
options.onResponse?.(currentTarget.url, response);
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
await cancelResponseBody(response);
|
|
536
|
+
await dispatcher.close();
|
|
537
|
+
throw error;
|
|
538
|
+
}
|
|
531
539
|
if (!redirectStatuses.has(response.status)) {
|
|
532
540
|
beginClosingDispatcher(dispatcher);
|
|
533
541
|
return { response, url: currentTarget.url };
|
|
@@ -541,15 +549,23 @@ export async function fetchPublicHttp(input, options = {}) {
|
|
|
541
549
|
beginClosingDispatcher(dispatcher);
|
|
542
550
|
return { response, url: currentTarget.url };
|
|
543
551
|
}
|
|
544
|
-
await cancelResponseBody(response);
|
|
545
|
-
await dispatcher.close();
|
|
546
552
|
let redirectUrl;
|
|
547
553
|
try {
|
|
548
554
|
redirectUrl = new URL(location, currentTarget.url);
|
|
549
555
|
}
|
|
550
556
|
catch {
|
|
557
|
+
await cancelResponseBody(response);
|
|
558
|
+
await dispatcher.close();
|
|
551
559
|
throw new PublicUrlError("Redirect target is not a valid URL");
|
|
552
560
|
}
|
|
561
|
+
if (options.allowRedirect && !options.allowRedirect(redirectUrl, currentTarget.url)) {
|
|
562
|
+
// Return the already validated redirect response instead of probing outside
|
|
563
|
+
// the caller's narrow scope. The original response body remains readable.
|
|
564
|
+
beginClosingDispatcher(dispatcher);
|
|
565
|
+
return { response, url: currentTarget.url };
|
|
566
|
+
}
|
|
567
|
+
await cancelResponseBody(response);
|
|
568
|
+
await dispatcher.close();
|
|
553
569
|
const nextTarget = await withAbortSignal(() => resolvePublicHttpUrl(redirectUrl), requestSignal);
|
|
554
570
|
if (nextTarget.url.origin !== currentTarget.url.origin && requestHeaders) {
|
|
555
571
|
// Manual redirect handling does not apply Fetch's cross-origin
|