mcp-web-validator 1.3.47 → 1.3.48
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 +10 -0
- package/README.md +55 -0
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/language-subtags.d.ts +2 -0
- package/dist/language-subtags.js +9 -0
- package/dist/language-subtags.js.map +1 -1
- package/dist/network.d.ts +3 -1
- package/dist/network.js +127 -21
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +1 -0
- package/dist/presentation.js +76 -21
- package/dist/presentation.js.map +1 -1
- package/dist/report.d.ts +1 -0
- package/dist/report.js +60 -21
- package/dist/report.js.map +1 -1
- package/dist/screenshot-proxy.d.ts +3 -0
- package/dist/screenshot-proxy.js +67 -14
- package/dist/screenshot-proxy.js.map +1 -1
- package/dist/screenshot.d.ts +6 -0
- package/dist/screenshot.js +191 -16
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.d.ts +5 -3
- package/dist/seo-auditor.js +417 -107
- package/dist/seo-auditor.js.map +1 -1
- package/dist/w3c-validator.js +46 -14
- package/dist/w3c-validator.js.map +1 -1
- package/package.json +3 -3
package/dist/seo-auditor.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as cheerio from "cheerio";
|
|
2
2
|
import { assertPublicHttpUrl, cancelResponseBody, fetchPublicHttp, getErrorMessage, PublicUrlError, } from "./network.js";
|
|
3
|
-
import { getPrimaryLanguageSubtag, isKnownPrimaryLanguageSubtag } from "./language-subtags.js";
|
|
3
|
+
import { getPrimaryLanguageSubtag, isKnownPrimaryLanguageSubtag, isRegisteredGrandfatheredILanguageTag, isWellFormedPrivateUseLanguageTag } from "./language-subtags.js";
|
|
4
4
|
import { PACKAGE_VERSION } from "./version.js";
|
|
5
5
|
export const MAX_AUDIT_ISSUES = 200;
|
|
6
|
+
const MAX_AUDIT_ELEMENT_CHARS = 500;
|
|
7
|
+
const MAX_AUDIT_MESSAGE_CHARS = 1_000;
|
|
6
8
|
export const MAX_LINKS_TO_CHECK = 25;
|
|
7
9
|
const LINK_CHECK_CONCURRENCY = 5;
|
|
8
10
|
const LINK_CHECK_TIMEOUT_MS = 5_000;
|
|
@@ -11,9 +13,31 @@ const HTTP_REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
|
11
13
|
export function isHttpRedirectStatus(status) {
|
|
12
14
|
return typeof status === "number" && HTTP_REDIRECT_STATUSES.has(status);
|
|
13
15
|
}
|
|
16
|
+
function isUnverifiedServerError(status) {
|
|
17
|
+
// Even a persistent server failure does not prove the destination is missing.
|
|
18
|
+
// Keep the bounded GET confirmation for HEAD 500/501 and the distinct TLS diagnostics.
|
|
19
|
+
return status >= 500 && status <= 599 && status !== 525 && status !== 526;
|
|
20
|
+
}
|
|
21
|
+
/** Ambiguous responses, access restrictions and network errors cannot establish destination health. */
|
|
22
|
+
export function isUnverifiedLinkStatus(status) {
|
|
23
|
+
return typeof status !== "number"
|
|
24
|
+
|| (status >= 300 && status < 400 && !isHttpRedirectStatus(status))
|
|
25
|
+
|| isUnverifiedServerError(status)
|
|
26
|
+
|| [401, 403, 406, 407, 408, 409, 411, 412, 415, 416, 417, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451].includes(status);
|
|
27
|
+
}
|
|
14
28
|
function addIssue(issues, issue) {
|
|
15
29
|
if (issues.length < MAX_AUDIT_ISSUES) {
|
|
16
|
-
|
|
30
|
+
// Untrusted source text must not dominate an MCP response via either
|
|
31
|
+
// an element snippet or the issue's diagnostic message.
|
|
32
|
+
issues.push({
|
|
33
|
+
...issue,
|
|
34
|
+
...(issue.message.length > MAX_AUDIT_MESSAGE_CHARS
|
|
35
|
+
? { message: `${issue.message.slice(0, MAX_AUDIT_MESSAGE_CHARS - 3)}...` }
|
|
36
|
+
: {}),
|
|
37
|
+
...(issue.element && issue.element.length > MAX_AUDIT_ELEMENT_CHARS
|
|
38
|
+
? { element: `${issue.element.slice(0, MAX_AUDIT_ELEMENT_CHARS - 3)}...` }
|
|
39
|
+
: {}),
|
|
40
|
+
});
|
|
17
41
|
}
|
|
18
42
|
}
|
|
19
43
|
function createIssueCollector() {
|
|
@@ -41,10 +65,16 @@ function isJsonLdScriptType(type) {
|
|
|
41
65
|
return type?.split(";", 1)[0].trim().toLowerCase() === "application/ld+json";
|
|
42
66
|
}
|
|
43
67
|
function hasJsonLdDocumentShape(value) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
const isObject = (entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry);
|
|
69
|
+
const documents = Array.isArray(value) ? value : [value];
|
|
70
|
+
return documents.every((entry) => {
|
|
71
|
+
if (!isObject(entry))
|
|
72
|
+
return false;
|
|
73
|
+
if (!Object.hasOwn(entry, "@graph"))
|
|
74
|
+
return true;
|
|
75
|
+
const graph = entry["@graph"];
|
|
76
|
+
return Array.isArray(graph) ? graph.every(isObject) : isObject(graph);
|
|
77
|
+
});
|
|
48
78
|
}
|
|
49
79
|
function isInTemplateContents(element) {
|
|
50
80
|
let node = element;
|
|
@@ -55,48 +85,136 @@ function isInTemplateContents(element) {
|
|
|
55
85
|
}
|
|
56
86
|
return false;
|
|
57
87
|
}
|
|
58
|
-
function
|
|
88
|
+
function hasGoogleNoindexHeader(value) {
|
|
89
|
+
if (!value)
|
|
90
|
+
return false;
|
|
91
|
+
// Each newline represents a separate response-header field; a crawler scope
|
|
92
|
+
// applies only to following comma-separated directives in that field.
|
|
93
|
+
for (const line of value.split(/\r?\n/)) {
|
|
94
|
+
let appliesToGoogle = true;
|
|
95
|
+
for (const part of line.split(",")) {
|
|
96
|
+
const directive = part.trim().toLowerCase();
|
|
97
|
+
const scoped = /^([a-z][a-z0-9_-]*):\s*(.+)$/.exec(directive);
|
|
98
|
+
// Colon-valued robots directives do not change the crawler scope of
|
|
99
|
+
// subsequent comma-separated directives in the same header field.
|
|
100
|
+
if (scoped && !["max-snippet", "max-image-preview", "max-video-preview", "unavailable_after"].includes(scoped[1])) {
|
|
101
|
+
appliesToGoogle = scoped[1] === "googlebot";
|
|
102
|
+
}
|
|
103
|
+
const action = scoped ? scoped[2].trim() : directive;
|
|
104
|
+
if (appliesToGoogle && (action === "noindex" || action === "none"))
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
function hasAmbiguousFoldedXRobotsNoindex(value) {
|
|
111
|
+
if (!value)
|
|
112
|
+
return false;
|
|
113
|
+
const parameterizedRules = new Set([
|
|
114
|
+
"max-snippet", "max-image-preview", "max-video-preview", "unavailable_after",
|
|
115
|
+
]);
|
|
116
|
+
// Preserve explicit field boundaries; only comma-folded directives are ambiguous.
|
|
117
|
+
for (const line of value.split(/\r?\n/)) {
|
|
118
|
+
let nonGoogleScope = false;
|
|
119
|
+
for (const part of line.split(",")) {
|
|
120
|
+
const directive = part.trim().toLowerCase();
|
|
121
|
+
const scoped = /^([a-z][a-z0-9_-]*):\s*(.+)$/.exec(directive);
|
|
122
|
+
if (scoped && !parameterizedRules.has(scoped[1])) {
|
|
123
|
+
nonGoogleScope = scoped[1] !== "googlebot";
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (nonGoogleScope && (directive === "noindex" || directive === "none"))
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
function inlineStyleValue(style, property) {
|
|
133
|
+
let selected;
|
|
134
|
+
let selectedImportant = false;
|
|
135
|
+
for (const declaration of style.split(";")) {
|
|
136
|
+
const separator = declaration.indexOf(":");
|
|
137
|
+
if (separator < 0 || declaration.slice(0, separator).trim().toLowerCase() !== property)
|
|
138
|
+
continue;
|
|
139
|
+
const raw = declaration.slice(separator + 1).trim().toLowerCase();
|
|
140
|
+
const important = /\s*!\s*important\s*$/.test(raw);
|
|
141
|
+
const value = raw.replace(/\s*!\s*important\s*$/, "").trim();
|
|
142
|
+
if (value && (!selectedImportant || important)) {
|
|
143
|
+
selected = value;
|
|
144
|
+
selectedImportant = important;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return selected;
|
|
148
|
+
}
|
|
149
|
+
function isHiddenFromAccessibilityTree(element) {
|
|
59
150
|
let node = element;
|
|
151
|
+
let childWithinParent = null;
|
|
152
|
+
let inheritedVisibility;
|
|
60
153
|
while (node) {
|
|
61
|
-
|
|
154
|
+
const attrs = node.attribs;
|
|
155
|
+
// User-agent styles hide a dialog and its descendants until the boolean open attribute is set.
|
|
156
|
+
if (node.name?.toLowerCase() === "dialog"
|
|
157
|
+
&& !Object.hasOwn(attrs ?? {}, "open"))
|
|
158
|
+
return true;
|
|
159
|
+
// A popover starts hidden until script or a user action shows it; static HTML has no open state.
|
|
160
|
+
if (attrs && Object.hasOwn(attrs, "popover"))
|
|
161
|
+
return true;
|
|
162
|
+
if (childWithinParent && node.name?.toLowerCase() === "details" && !Object.hasOwn(attrs ?? {}, "open")) {
|
|
163
|
+
// Closed details exposes its first direct summary, not the remaining descendants.
|
|
164
|
+
const summary = node.children?.find((child) => child.name?.toLowerCase() === "summary");
|
|
165
|
+
if (childWithinParent !== summary)
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (attrs?.["aria-hidden"]?.trim().toLowerCase() === "true")
|
|
62
169
|
return true;
|
|
170
|
+
if (attrs && Object.hasOwn(attrs, "hidden"))
|
|
171
|
+
return true;
|
|
172
|
+
// The boolean inert attribute excludes its entire subtree, regardless of its string value.
|
|
173
|
+
if (attrs && Object.hasOwn(attrs, "inert"))
|
|
174
|
+
return true;
|
|
175
|
+
const style = attrs?.style ?? "";
|
|
176
|
+
if (inlineStyleValue(style, "display") === "none"
|
|
177
|
+
|| inlineStyleValue(style, "content-visibility") === "hidden")
|
|
178
|
+
return true;
|
|
179
|
+
// Visibility inherits but a descendant can explicitly restore visibility.
|
|
180
|
+
if (inheritedVisibility === undefined) {
|
|
181
|
+
const visibility = inlineStyleValue(style, "visibility");
|
|
182
|
+
if (visibility === "visible" || visibility === "hidden" || visibility === "collapse") {
|
|
183
|
+
inheritedVisibility = visibility;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
childWithinParent = node;
|
|
63
187
|
node = (node.parent ?? null);
|
|
64
188
|
}
|
|
65
|
-
return
|
|
189
|
+
return inheritedVisibility === "hidden" || inheritedVisibility === "collapse";
|
|
66
190
|
}
|
|
67
191
|
function referencedTextContent(element) {
|
|
68
192
|
const root = element;
|
|
69
|
-
const isHidden = (node) => {
|
|
70
|
-
const attrs = node.attribs;
|
|
71
|
-
if (!attrs)
|
|
72
|
-
return false;
|
|
73
|
-
if (Object.prototype.hasOwnProperty.call(attrs, "hidden")
|
|
74
|
-
|| attrs["aria-hidden"]?.trim().toLowerCase() === "true")
|
|
75
|
-
return true;
|
|
76
|
-
return (attrs.style ?? "").split(";").some((declaration) => {
|
|
77
|
-
const [property, rawValue] = declaration.split(":");
|
|
78
|
-
const value = rawValue?.trim().toLowerCase().replace(/\s*!important\s*$/, "");
|
|
79
|
-
switch (property?.trim().toLowerCase()) {
|
|
80
|
-
case "display": return value === "none";
|
|
81
|
-
case "visibility": return value === "hidden" || value === "collapse";
|
|
82
|
-
case "content-visibility": return value === "hidden";
|
|
83
|
-
default: return false;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
193
|
// A directly referenced hidden root contributes its full subtree; hidden descendants of a visible root do not.
|
|
88
|
-
|
|
89
|
-
for (let ancestor = root; ancestor; ancestor = ancestor.parent) {
|
|
90
|
-
if (isHidden(ancestor)) {
|
|
91
|
-
hiddenReference = true;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
194
|
+
const hiddenReference = isHiddenFromAccessibilityTree(root);
|
|
95
195
|
const traverse = (node) => {
|
|
96
|
-
|
|
196
|
+
// Script, stylesheet and template contents never supply rendered label text.
|
|
197
|
+
if (node.name && ["script", "style", "template"].includes(node.name.toLowerCase()))
|
|
97
198
|
return "";
|
|
98
|
-
if (node
|
|
99
|
-
|
|
199
|
+
if (!hiddenReference && node !== root) {
|
|
200
|
+
const attrs = node.attribs;
|
|
201
|
+
// Visibility can be restored deeper in the subtree; display, inert and aria-hidden cannot.
|
|
202
|
+
if (attrs && (Object.hasOwn(attrs, "hidden") || Object.hasOwn(attrs, "inert")
|
|
203
|
+
|| attrs["aria-hidden"]?.trim().toLowerCase() === "true"
|
|
204
|
+
|| inlineStyleValue(attrs.style ?? "", "display") === "none"
|
|
205
|
+
|| inlineStyleValue(attrs.style ?? "", "content-visibility") === "hidden"))
|
|
206
|
+
return "";
|
|
207
|
+
}
|
|
208
|
+
if (node.type === "text") {
|
|
209
|
+
return !hiddenReference && isHiddenFromAccessibilityTree(node) ? "" : (node.data ?? "");
|
|
210
|
+
}
|
|
211
|
+
// Accessible name-from-content includes an embedded image's text alternative,
|
|
212
|
+
// not just literal text nodes in the referenced label.
|
|
213
|
+
if (node.name?.toLowerCase() === "img" && !isUnambiguouslyPresentationalElement(node)) {
|
|
214
|
+
if (!hiddenReference && isHiddenFromAccessibilityTree(node))
|
|
215
|
+
return "";
|
|
216
|
+
return node.attribs?.alt?.trim() ?? "";
|
|
217
|
+
}
|
|
100
218
|
return (node.children ?? []).map(traverse).join("");
|
|
101
219
|
};
|
|
102
220
|
return traverse(root).trim();
|
|
@@ -128,22 +246,12 @@ function explicitSemanticRole(element) {
|
|
|
128
246
|
.map((token) => token.toLowerCase())
|
|
129
247
|
.find((token) => VALID_NON_ABSTRACT_ARIA_ROLES.has(token));
|
|
130
248
|
}
|
|
131
|
-
function
|
|
132
|
-
const value = element?.attribs?.tabindex?.trim();
|
|
133
|
-
if (!value || !/^[+-]?\d+$/.test(value))
|
|
134
|
-
return false;
|
|
135
|
-
return Number(value) < 0;
|
|
136
|
-
}
|
|
137
|
-
function isDecorativeIframe(element) {
|
|
138
|
-
const role = explicitSemanticRole(element);
|
|
139
|
-
return role === "none" || role === "presentation";
|
|
140
|
-
}
|
|
141
|
-
function isUnambiguouslyPresentationalImage(element) {
|
|
249
|
+
function isUnambiguouslyPresentationalElement(element) {
|
|
142
250
|
const attribs = element?.attribs ?? {};
|
|
143
251
|
const role = explicitSemanticRole(element);
|
|
144
252
|
if (role !== "none" && role !== "presentation")
|
|
145
253
|
return false;
|
|
146
|
-
// Presentational roles are ignored when an
|
|
254
|
+
// Presentational roles are ignored when an image or iframe can take focus. Treat any
|
|
147
255
|
// explicit tabindex as a potential conflict instead of guessing whether the
|
|
148
256
|
// authored value will be focusable in a particular user agent.
|
|
149
257
|
if (attribs.tabindex !== undefined)
|
|
@@ -273,10 +381,27 @@ function canParseCanonicalHref(href) {
|
|
|
273
381
|
return false;
|
|
274
382
|
}
|
|
275
383
|
}
|
|
384
|
+
function isUsableOpenGraphUrl(value) {
|
|
385
|
+
try {
|
|
386
|
+
const url = new URL(value);
|
|
387
|
+
return (url.protocol === "http:" || url.protocol === "https:")
|
|
388
|
+
&& Boolean(url.hostname) && !url.username && !url.password;
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const editorialGraphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
395
|
+
function countEditorialCharacters(text) {
|
|
396
|
+
let count = 0;
|
|
397
|
+
for (const _ of editorialGraphemes.segment(text))
|
|
398
|
+
count += 1;
|
|
399
|
+
return count;
|
|
400
|
+
}
|
|
276
401
|
/**
|
|
277
402
|
* Audits technical SEO and accessibility basics on HTML content using Cheerio
|
|
278
403
|
*/
|
|
279
|
-
export function auditSeoMetadataDetailed(htmlContent) {
|
|
404
|
+
export function auditSeoMetadataDetailed(htmlContent, xRobotsTag) {
|
|
280
405
|
const $ = cheerio.load(htmlContent, { sourceCodeLocationInfo: true });
|
|
281
406
|
const collector = createIssueCollector();
|
|
282
407
|
const { add } = collector;
|
|
@@ -300,7 +425,8 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
300
425
|
});
|
|
301
426
|
}
|
|
302
427
|
const titleText = titleTag.first().text().trim();
|
|
303
|
-
|
|
428
|
+
const titleLength = countEditorialCharacters(titleText);
|
|
429
|
+
if (titleLength === 0) {
|
|
304
430
|
add({
|
|
305
431
|
code: "seo.title.missing_or_empty",
|
|
306
432
|
severity: "error",
|
|
@@ -308,21 +434,21 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
308
434
|
message: "The <title> tag is empty.",
|
|
309
435
|
});
|
|
310
436
|
}
|
|
311
|
-
else if (
|
|
437
|
+
else if (titleLength < 30) {
|
|
312
438
|
add({
|
|
313
439
|
code: "seo.title.length",
|
|
314
440
|
severity: "info",
|
|
315
441
|
category: "SEO",
|
|
316
|
-
message: `Title is ${
|
|
442
|
+
message: `Title is ${titleLength} characters. This is shorter than the audit's common editorial range; review whether it describes the page clearly.`,
|
|
317
443
|
element: `<title>${titleText}</title>`,
|
|
318
444
|
});
|
|
319
445
|
}
|
|
320
|
-
else if (
|
|
446
|
+
else if (titleLength > 60) {
|
|
321
447
|
add({
|
|
322
448
|
code: "seo.title.length",
|
|
323
449
|
severity: "info",
|
|
324
450
|
category: "SEO",
|
|
325
|
-
message: `Title is ${
|
|
451
|
+
message: `Title is ${titleLength} characters. This is longer than the audit's common editorial range; Google title links may be shortened or rewritten depending on context and device.`,
|
|
326
452
|
element: `<title>${titleText}</title>`,
|
|
327
453
|
});
|
|
328
454
|
}
|
|
@@ -347,7 +473,8 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
347
473
|
});
|
|
348
474
|
}
|
|
349
475
|
const descText = metaDescription.first().attr("content")?.trim() || "";
|
|
350
|
-
|
|
476
|
+
const descriptionLength = countEditorialCharacters(descText);
|
|
477
|
+
if (descriptionLength === 0) {
|
|
351
478
|
add({
|
|
352
479
|
code: "seo.meta_description.missing_or_empty",
|
|
353
480
|
severity: "error",
|
|
@@ -355,21 +482,21 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
355
482
|
message: "Meta description content attribute is empty.",
|
|
356
483
|
});
|
|
357
484
|
}
|
|
358
|
-
else if (
|
|
485
|
+
else if (descriptionLength < 120) {
|
|
359
486
|
add({
|
|
360
487
|
code: "seo.meta_description.length",
|
|
361
488
|
severity: "info",
|
|
362
489
|
category: "SEO",
|
|
363
|
-
message: `Meta description is ${
|
|
490
|
+
message: `Meta description is ${descriptionLength} characters. This is shorter than the audit's common editorial range; review whether it provides a useful page summary.`,
|
|
364
491
|
element: `<meta name="description" content="${descText}">`,
|
|
365
492
|
});
|
|
366
493
|
}
|
|
367
|
-
else if (
|
|
494
|
+
else if (descriptionLength > 160) {
|
|
368
495
|
add({
|
|
369
496
|
code: "seo.meta_description.length",
|
|
370
497
|
severity: "info",
|
|
371
498
|
category: "SEO",
|
|
372
|
-
message: `Meta description is ${
|
|
499
|
+
message: `Meta description is ${descriptionLength} characters. This is longer than the audit's common editorial range; displayed snippets may be shortened depending on the query and device.`,
|
|
373
500
|
element: `<meta name="description" content="${descText}">`,
|
|
374
501
|
});
|
|
375
502
|
}
|
|
@@ -386,6 +513,11 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
386
513
|
const parseableCanonical = nonEmptyCanonical.filter((_, element) => canParseCanonicalHref(($(element).attr("href") ?? "").trim()));
|
|
387
514
|
const invalidCanonical = nonEmptyCanonical.filter((_, element) => !canParseCanonicalHref(($(element).attr("href") ?? "").trim()));
|
|
388
515
|
const usableCanonical = parseableCanonical.filter((_, element) => !["hreflang", "lang", "media", "type"].some((attribute) => $(element).attr(attribute) !== undefined));
|
|
516
|
+
const credentialedCanonical = parseableCanonical.filter((_, element) => {
|
|
517
|
+
const href = ($(element).attr("href") ?? "").trim();
|
|
518
|
+
const url = new URL(href, "https://example.invalid/");
|
|
519
|
+
return Boolean(url.username || url.password);
|
|
520
|
+
});
|
|
389
521
|
if (invalidCanonical.length > 0) {
|
|
390
522
|
add({
|
|
391
523
|
code: "seo.canonical.invalid_url",
|
|
@@ -394,6 +526,14 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
394
526
|
message: "Canonical link href is not a usable HTTP(S) URL. Provide an HTTP(S) canonical target or remove the declaration.",
|
|
395
527
|
});
|
|
396
528
|
}
|
|
529
|
+
if (credentialedCanonical.length > 0) {
|
|
530
|
+
add({
|
|
531
|
+
code: "seo.canonical.embedded_credentials",
|
|
532
|
+
severity: "warning",
|
|
533
|
+
category: "SEO",
|
|
534
|
+
message: "Canonical URL embeds user credentials. Remove the username and password to avoid exposing secrets or relying on authenticated canonical targets.",
|
|
535
|
+
});
|
|
536
|
+
}
|
|
397
537
|
if (usableCanonical.filter((_, element) => ($(element).attr("href") ?? "").includes("#")).length > 0) {
|
|
398
538
|
add({
|
|
399
539
|
code: "seo.canonical.fragment_unsupported",
|
|
@@ -459,7 +599,7 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
459
599
|
.split(",")
|
|
460
600
|
.some((directive) => ["noindex", "none"].includes(directive.trim().toLowerCase()));
|
|
461
601
|
});
|
|
462
|
-
if (indexBlockingRobotsMeta.length > 0) {
|
|
602
|
+
if (indexBlockingRobotsMeta.length > 0 || hasGoogleNoindexHeader(xRobotsTag)) {
|
|
463
603
|
add({
|
|
464
604
|
code: "seo.robots.noindex",
|
|
465
605
|
severity: "warning",
|
|
@@ -467,6 +607,14 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
467
607
|
message: "A robots directive prevents Google from indexing this page. Confirm that noindex is intentional.",
|
|
468
608
|
});
|
|
469
609
|
}
|
|
610
|
+
if (hasAmbiguousFoldedXRobotsNoindex(xRobotsTag)) {
|
|
611
|
+
add({
|
|
612
|
+
code: "seo.robots.x_robots_tag.scope_ambiguous",
|
|
613
|
+
severity: "info",
|
|
614
|
+
category: "SEO",
|
|
615
|
+
message: "X-Robots-Tag contains a potentially ambiguous noindex after a non-Googlebot scope. Combined HTTP header fields may hide a separate global directive; inspect the origin response headers.",
|
|
616
|
+
});
|
|
617
|
+
}
|
|
470
618
|
// --- Viewport Meta Tag (Mobile Responsiveness) ---
|
|
471
619
|
const viewport = $('head > meta[name="viewport" i]');
|
|
472
620
|
if (viewport.length === 0) {
|
|
@@ -547,8 +695,8 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
547
695
|
});
|
|
548
696
|
// --- Images Alt Tags (SEO + Accessibility) ---
|
|
549
697
|
$("img").filter((_, element) => !isInTemplateContents(element)
|
|
550
|
-
&& !
|
|
551
|
-
&& !
|
|
698
|
+
&& !isHiddenFromAccessibilityTree(element)
|
|
699
|
+
&& !isUnambiguouslyPresentationalElement(element)).each((_, element) => {
|
|
552
700
|
const img = $(element);
|
|
553
701
|
const src = img.attr("src") || "unknown-source";
|
|
554
702
|
const alt = img.attr("alt");
|
|
@@ -569,19 +717,22 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
569
717
|
element: `<img src="${src}">`,
|
|
570
718
|
});
|
|
571
719
|
}
|
|
572
|
-
else if (alt !== undefined && alt !== "" && alt.trim() === "") {
|
|
720
|
+
else if (alt !== undefined && alt !== "" && alt.trim() === "" && !hasAlternateAccessibleName) {
|
|
573
721
|
add({
|
|
574
722
|
code: "accessibility.image_alt.empty",
|
|
575
|
-
severity: "
|
|
723
|
+
severity: "error",
|
|
576
724
|
category: "Accessibility",
|
|
577
725
|
message: "Whitespace-only 'alt' text does not provide an accessible name. Use alt=\"\" for a decorative image or meaningful alternative text for an informative image.",
|
|
578
726
|
element: `<img src="${src}" alt="${alt}">`,
|
|
579
727
|
});
|
|
580
728
|
}
|
|
581
729
|
});
|
|
582
|
-
$("
|
|
730
|
+
$("[role]").filter((_, element) => element.namespace === "http://www.w3.org/1999/xhtml"
|
|
731
|
+
// Native images, image inputs and image-map areas have separate naming rules below.
|
|
732
|
+
&& !["img", "input", "area"].includes(element.name.toLowerCase())
|
|
733
|
+
&& hasExplicitSemanticImageRole(element)
|
|
583
734
|
&& !isInTemplateContents(element)
|
|
584
|
-
&& !
|
|
735
|
+
&& !isHiddenFromAccessibilityTree(element)).each((_, element) => {
|
|
585
736
|
const semanticImage = $(element);
|
|
586
737
|
const labelledByIds = (semanticImage.attr("aria-labelledby") ?? "")
|
|
587
738
|
.trim()
|
|
@@ -601,7 +752,7 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
601
752
|
});
|
|
602
753
|
$("[role]").filter((_, element) => hasExplicitSvgImageRole(element)
|
|
603
754
|
&& !isInTemplateContents(element)
|
|
604
|
-
&& !
|
|
755
|
+
&& !isHiddenFromAccessibilityTree(element)).each((_, element) => {
|
|
605
756
|
const svgImage = $(element);
|
|
606
757
|
const labelledByIds = (svgImage.attr("aria-labelledby") ?? "")
|
|
607
758
|
.trim()
|
|
@@ -619,7 +770,7 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
619
770
|
});
|
|
620
771
|
}
|
|
621
772
|
});
|
|
622
|
-
$("input[type=\"image\" i]").filter((_, element) => !isInTemplateContents(element) && !
|
|
773
|
+
$("input[type=\"image\" i]").filter((_, element) => !isInTemplateContents(element) && !isHiddenFromAccessibilityTree(element)).each((_, element) => {
|
|
623
774
|
const input = $(element);
|
|
624
775
|
const labelledByIds = (input.attr("aria-labelledby") ?? "")
|
|
625
776
|
.trim()
|
|
@@ -640,9 +791,8 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
640
791
|
}
|
|
641
792
|
});
|
|
642
793
|
$("iframe").filter((_, element) => !isInTemplateContents(element)
|
|
643
|
-
&& !
|
|
644
|
-
&& !
|
|
645
|
-
&& !isDecorativeIframe(element)).each((_, element) => {
|
|
794
|
+
&& !isHiddenFromAccessibilityTree(element)
|
|
795
|
+
&& !isUnambiguouslyPresentationalElement(element)).each((_, element) => {
|
|
646
796
|
const iframe = $(element);
|
|
647
797
|
const labelledByIds = (iframe.attr("aria-labelledby") ?? "")
|
|
648
798
|
.trim()
|
|
@@ -660,7 +810,7 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
660
810
|
});
|
|
661
811
|
}
|
|
662
812
|
});
|
|
663
|
-
$("area[href]").filter((_, element) => !isInTemplateContents(element) && !
|
|
813
|
+
$("area[href]").filter((_, element) => !isInTemplateContents(element) && !isHiddenFromAccessibilityTree(element)).each((_, element) => {
|
|
664
814
|
const area = $(element);
|
|
665
815
|
const labelledByIds = (area.attr("aria-labelledby") ?? "")
|
|
666
816
|
.trim()
|
|
@@ -674,10 +824,18 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
674
824
|
if (needsAccessibleName) {
|
|
675
825
|
const href = area.attr("href")?.trim() ?? "";
|
|
676
826
|
const map = area.closest("map");
|
|
677
|
-
const hasLabeledEquivalent = map.find("area[href]").filter((_, peer) =>
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
827
|
+
const hasLabeledEquivalent = map.find("area[href]").filter((_, peer) => {
|
|
828
|
+
const peerArea = $(peer);
|
|
829
|
+
const peerLabelledByIds = (peerArea.attr("aria-labelledby") ?? "")
|
|
830
|
+
.trim().split(/[\t\n\f\r ]+/).filter(Boolean);
|
|
831
|
+
return !isInTemplateContents(peer)
|
|
832
|
+
&& !isHiddenFromAccessibilityTree(peer)
|
|
833
|
+
&& (peerArea.attr("href")?.trim() ?? "") === href
|
|
834
|
+
&& (Boolean(peerArea.attr("alt")?.trim())
|
|
835
|
+
|| Boolean(peerArea.attr("aria-label")?.trim())
|
|
836
|
+
|| Boolean(peerArea.attr("title")?.trim())
|
|
837
|
+
|| peerLabelledByIds.some((id) => Boolean(textById.get(id))));
|
|
838
|
+
}).length > 0;
|
|
681
839
|
needsAccessibleName = !hasLabeledEquivalent;
|
|
682
840
|
}
|
|
683
841
|
if (needsAccessibleName) {
|
|
@@ -692,7 +850,9 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
692
850
|
const htmlElement = $("html").first();
|
|
693
851
|
const htmlNode = htmlElement.get(0);
|
|
694
852
|
if (htmlNode?.sourceCodeLocation) {
|
|
695
|
-
const
|
|
853
|
+
const isXhtml = htmlElement.attr("xmlns") === "http://www.w3.org/1999/xhtml";
|
|
854
|
+
const pageLanguage = htmlElement.attr("lang")?.trim()
|
|
855
|
+
|| (isXhtml ? htmlElement.attr("xml:lang")?.trim() : undefined);
|
|
696
856
|
if (!pageLanguage) {
|
|
697
857
|
add({
|
|
698
858
|
code: "accessibility.page_language.missing_or_empty",
|
|
@@ -703,7 +863,15 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
703
863
|
}
|
|
704
864
|
else {
|
|
705
865
|
const primaryLanguageSubtag = getPrimaryLanguageSubtag(pageLanguage);
|
|
706
|
-
if (
|
|
866
|
+
if (isWellFormedPrivateUseLanguageTag(pageLanguage)) {
|
|
867
|
+
add({
|
|
868
|
+
code: "accessibility.page_language.private_use",
|
|
869
|
+
severity: "info",
|
|
870
|
+
category: "Accessibility",
|
|
871
|
+
message: "This is a valid private-use BCP 47 language tag, but assistive technologies may not recognize it. Prefer a registered language tag when one applies.",
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
else if (!isRegisteredGrandfatheredILanguageTag(pageLanguage) && !isKnownPrimaryLanguageSubtag(primaryLanguageSubtag)) {
|
|
707
875
|
add({
|
|
708
876
|
code: "accessibility.page_language.invalid_primary_subtag",
|
|
709
877
|
severity: "error",
|
|
@@ -711,11 +879,19 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
711
879
|
message: `The document <html> lang attribute uses unknown primary language subtag "${primaryLanguageSubtag}". Use a primary language subtag registered by IANA.`,
|
|
712
880
|
});
|
|
713
881
|
}
|
|
882
|
+
else if (!pageLanguage.split("-").every((subtag) => /^[a-z0-9]{1,8}$/i.test(subtag))) {
|
|
883
|
+
add({
|
|
884
|
+
code: "accessibility.page_language.malformed_subtag",
|
|
885
|
+
severity: "error",
|
|
886
|
+
category: "Accessibility",
|
|
887
|
+
message: "The document <html> lang attribute has a malformed BCP 47 subtag. Use hyphen-separated ASCII letters or digits, with 1-8 characters per subtag.",
|
|
888
|
+
});
|
|
889
|
+
}
|
|
714
890
|
}
|
|
715
891
|
}
|
|
716
892
|
// --- Open Graph / Social Tags ---
|
|
717
893
|
const requiredOpenGraphProperties = ["og:title", "og:type", "og:image", "og:url"];
|
|
718
|
-
const hasCompleteOpenGraphMetadata = requiredOpenGraphProperties.every((property) => $(`head > meta[property="${property}"]`).
|
|
894
|
+
const hasCompleteOpenGraphMetadata = requiredOpenGraphProperties.every((property) => Boolean($(`head > meta[property="${property}"]`).first().attr("content")?.trim()));
|
|
719
895
|
if (!hasCompleteOpenGraphMetadata) {
|
|
720
896
|
add({
|
|
721
897
|
code: "seo.open_graph.missing",
|
|
@@ -724,10 +900,23 @@ export function auditSeoMetadataDetailed(htmlContent) {
|
|
|
724
900
|
message: "Open Graph basic metadata is incomplete or empty. Provide non-empty og:title, og:type, og:image, and og:url values.",
|
|
725
901
|
});
|
|
726
902
|
}
|
|
903
|
+
// Open Graph gives the first declaration precedence; a later valid URL
|
|
904
|
+
// cannot reliably repair an invalid first image or canonical identity.
|
|
905
|
+
for (const property of ["og:image", "og:url"]) {
|
|
906
|
+
const value = $(`head > meta[property="${property}"]`).first().attr("content")?.trim();
|
|
907
|
+
if (value && !isUsableOpenGraphUrl(value)) {
|
|
908
|
+
add({
|
|
909
|
+
code: "seo.open_graph.invalid_url",
|
|
910
|
+
severity: "warning",
|
|
911
|
+
category: "SEO",
|
|
912
|
+
message: `Open Graph ${property} needs an absolute HTTP(S) URL without embedded credentials for reliable social previews.`,
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
727
916
|
return collector.details();
|
|
728
917
|
}
|
|
729
|
-
export function auditSeoMetadata(htmlContent) {
|
|
730
|
-
return auditSeoMetadataDetailed(htmlContent).issues;
|
|
918
|
+
export function auditSeoMetadata(htmlContent, xRobotsTag) {
|
|
919
|
+
return auditSeoMetadataDetailed(htmlContent, xRobotsTag).issues;
|
|
731
920
|
}
|
|
732
921
|
/**
|
|
733
922
|
* Parses and validates JSON-LD Schema markup
|
|
@@ -776,7 +965,7 @@ export function validateSchemaMarkup(htmlContent) {
|
|
|
776
965
|
return validateSchemaMarkupDetailed(htmlContent).issues;
|
|
777
966
|
}
|
|
778
967
|
/**
|
|
779
|
-
* Extracts and tests links,
|
|
968
|
+
* Extracts and tests links, distinguishing reachable, failed and unverified responses.
|
|
780
969
|
*/
|
|
781
970
|
export async function checkBrokenLinks(htmlContent, baseUrl, maxLinks = MAX_LINKS_TO_CHECK) {
|
|
782
971
|
if (!Number.isSafeInteger(maxLinks) || maxLinks <= 0) {
|
|
@@ -857,17 +1046,28 @@ export async function checkBrokenLinks(htmlContent, baseUrl, maxLinks = MAX_LINK
|
|
|
857
1046
|
let nextIndex = 0;
|
|
858
1047
|
async function checkLink(url) {
|
|
859
1048
|
try {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1049
|
+
let headResult;
|
|
1050
|
+
try {
|
|
1051
|
+
headResult = await fetchPublicHttp(url, {
|
|
1052
|
+
method: "HEAD",
|
|
1053
|
+
headers: { "User-Agent": LINK_CHECK_USER_AGENT },
|
|
1054
|
+
timeoutMs: LINK_CHECK_TIMEOUT_MS,
|
|
1055
|
+
maxRedirects: 0,
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
catch (error) {
|
|
1059
|
+
// An origin may reject HEAD at the transport layer while accepting GET.
|
|
1060
|
+
// Never retry URL-policy failures or expired request deadlines.
|
|
1061
|
+
if (!(error instanceof TypeError))
|
|
1062
|
+
throw error;
|
|
1063
|
+
}
|
|
1064
|
+
const headStatus = headResult?.response.status;
|
|
1065
|
+
const headFinalUrl = headResult?.url.href ?? url;
|
|
1066
|
+
if (headResult)
|
|
1067
|
+
await cancelResponseBody(headResult.response);
|
|
1068
|
+
// Some sites reject HEAD with 400/405, fail its transport, or return a
|
|
1069
|
+
// false 404/410 for an available resource. Confirm with a bounded GET.
|
|
1070
|
+
if (headStatus === undefined || [304, 400, 401, 403, 404, 405, 406, 408, 409, 410, 411, 412, 415, 416, 417, 422, 424, 500, 501].includes(headStatus)) {
|
|
871
1071
|
let getResult = await fetchPublicHttp(url, {
|
|
872
1072
|
method: "GET",
|
|
873
1073
|
headers: {
|
|
@@ -877,7 +1077,9 @@ export async function checkBrokenLinks(htmlContent, baseUrl, maxLinks = MAX_LINK
|
|
|
877
1077
|
timeoutMs: LINK_CHECK_TIMEOUT_MS,
|
|
878
1078
|
maxRedirects: 0,
|
|
879
1079
|
});
|
|
880
|
-
|
|
1080
|
+
// Some origins reject an otherwise valid GET solely because of Range;
|
|
1081
|
+
// confirm with an ordinary GET before declaring the link broken.
|
|
1082
|
+
if (getResult.response.status === 400 || getResult.response.status === 416) {
|
|
881
1083
|
await cancelResponseBody(getResult.response);
|
|
882
1084
|
getResult = await fetchPublicHttp(url, {
|
|
883
1085
|
method: "GET",
|
|
@@ -887,29 +1089,137 @@ export async function checkBrokenLinks(htmlContent, baseUrl, maxLinks = MAX_LINK
|
|
|
887
1089
|
});
|
|
888
1090
|
}
|
|
889
1091
|
const status = getResult.response.status;
|
|
890
|
-
const ok = status >= 200 && status < 400;
|
|
1092
|
+
const ok = status >= 200 && status < 400 && !isUnverifiedLinkStatus(status);
|
|
891
1093
|
const finalUrl = getResult.url.href;
|
|
892
1094
|
await cancelResponseBody(getResult.response);
|
|
893
1095
|
return {
|
|
894
1096
|
url,
|
|
895
1097
|
status,
|
|
896
1098
|
ok,
|
|
897
|
-
message:
|
|
898
|
-
? "
|
|
899
|
-
:
|
|
900
|
-
?
|
|
901
|
-
:
|
|
1099
|
+
message: status === 300
|
|
1100
|
+
? "Multiple choices without a selected destination; availability not verified"
|
|
1101
|
+
: status === 304
|
|
1102
|
+
? "Not modified without a conditional request; destination availability not verified"
|
|
1103
|
+
: status === 401 || status === 403
|
|
1104
|
+
? "Access restricted; destination availability not verified"
|
|
1105
|
+
: status === 406
|
|
1106
|
+
? "Not acceptable under content negotiation; destination availability not verified"
|
|
1107
|
+
: status === 407
|
|
1108
|
+
? "Proxy authentication required; destination availability not verified"
|
|
1109
|
+
: status === 408
|
|
1110
|
+
? "Request timed out; destination availability not verified"
|
|
1111
|
+
: status === 409
|
|
1112
|
+
? "Request conflict; destination availability not verified"
|
|
1113
|
+
: status === 411
|
|
1114
|
+
? "Content length required; destination availability not verified"
|
|
1115
|
+
: status === 412
|
|
1116
|
+
? "Precondition failed; destination availability not verified"
|
|
1117
|
+
: status === 415
|
|
1118
|
+
? "Unsupported media type; destination availability not verified"
|
|
1119
|
+
: status === 416
|
|
1120
|
+
? "Range not satisfiable; destination availability not verified"
|
|
1121
|
+
: status === 417
|
|
1122
|
+
? "Expectation failed; destination availability not verified"
|
|
1123
|
+
: status === 421
|
|
1124
|
+
? "Request was misdirected; destination availability not verified"
|
|
1125
|
+
: status === 422
|
|
1126
|
+
? "Unprocessable request; destination availability not verified"
|
|
1127
|
+
: status === 423
|
|
1128
|
+
? "Resource locked; destination availability not verified"
|
|
1129
|
+
: status === 424
|
|
1130
|
+
? "Failed dependency; destination availability not verified"
|
|
1131
|
+
: status === 425
|
|
1132
|
+
? "Request rejected as Too Early; destination availability not verified"
|
|
1133
|
+
: status === 426
|
|
1134
|
+
? "Protocol upgrade required; destination availability not verified"
|
|
1135
|
+
: status === 428
|
|
1136
|
+
? "Precondition required; destination availability not verified"
|
|
1137
|
+
: status === 429
|
|
1138
|
+
? "Rate limited; destination availability not verified"
|
|
1139
|
+
: status === 431
|
|
1140
|
+
? "Request headers too large; destination availability not verified"
|
|
1141
|
+
: status === 451
|
|
1142
|
+
? "Unavailable for legal reasons; destination availability not verified"
|
|
1143
|
+
: status === 502 || status === 503 || status === 504 || (status >= 520 && status <= 524)
|
|
1144
|
+
? "Temporary gateway or service failure; destination availability not verified"
|
|
1145
|
+
: status === 511
|
|
1146
|
+
? "Network authentication required; destination availability not verified"
|
|
1147
|
+
: status === 525
|
|
1148
|
+
? "Cloudflare TLS handshake with origin failed; destination unavailable"
|
|
1149
|
+
: status === 526
|
|
1150
|
+
? "Cloudflare could not validate origin TLS certificate; destination unavailable"
|
|
1151
|
+
: isUnverifiedServerError(status)
|
|
1152
|
+
? "Server error; destination availability not verified"
|
|
1153
|
+
: isHttpRedirectStatus(status)
|
|
1154
|
+
? "Redirect not followed"
|
|
1155
|
+
: finalUrl !== url
|
|
1156
|
+
? `Redirected to ${finalUrl}`
|
|
1157
|
+
: undefined,
|
|
902
1158
|
};
|
|
903
1159
|
}
|
|
904
1160
|
return {
|
|
905
1161
|
url,
|
|
906
1162
|
status: headStatus,
|
|
907
|
-
ok: headStatus >= 200 && headStatus < 400,
|
|
908
|
-
message:
|
|
909
|
-
? "
|
|
910
|
-
:
|
|
911
|
-
?
|
|
912
|
-
:
|
|
1163
|
+
ok: headStatus >= 200 && headStatus < 400 && !isUnverifiedLinkStatus(headStatus),
|
|
1164
|
+
message: headStatus === 300
|
|
1165
|
+
? "Multiple choices without a selected destination; availability not verified"
|
|
1166
|
+
: headStatus === 304
|
|
1167
|
+
? "Not modified without a conditional request; destination availability not verified"
|
|
1168
|
+
: headStatus === 401 || headStatus === 403
|
|
1169
|
+
? "Access restricted; destination availability not verified"
|
|
1170
|
+
: headStatus === 406
|
|
1171
|
+
? "Not acceptable under content negotiation; destination availability not verified"
|
|
1172
|
+
: headStatus === 407
|
|
1173
|
+
? "Proxy authentication required; destination availability not verified"
|
|
1174
|
+
: headStatus === 408
|
|
1175
|
+
? "Request timed out; destination availability not verified"
|
|
1176
|
+
: headStatus === 409
|
|
1177
|
+
? "Request conflict; destination availability not verified"
|
|
1178
|
+
: headStatus === 411
|
|
1179
|
+
? "Content length required; destination availability not verified"
|
|
1180
|
+
: headStatus === 412
|
|
1181
|
+
? "Precondition failed; destination availability not verified"
|
|
1182
|
+
: headStatus === 415
|
|
1183
|
+
? "Unsupported media type; destination availability not verified"
|
|
1184
|
+
: headStatus === 416
|
|
1185
|
+
? "Range not satisfiable; destination availability not verified"
|
|
1186
|
+
: headStatus === 417
|
|
1187
|
+
? "Expectation failed; destination availability not verified"
|
|
1188
|
+
: headStatus === 421
|
|
1189
|
+
? "Request was misdirected; destination availability not verified"
|
|
1190
|
+
: headStatus === 422
|
|
1191
|
+
? "Unprocessable request; destination availability not verified"
|
|
1192
|
+
: headStatus === 423
|
|
1193
|
+
? "Resource locked; destination availability not verified"
|
|
1194
|
+
: headStatus === 424
|
|
1195
|
+
? "Failed dependency; destination availability not verified"
|
|
1196
|
+
: headStatus === 425
|
|
1197
|
+
? "Request rejected as Too Early; destination availability not verified"
|
|
1198
|
+
: headStatus === 426
|
|
1199
|
+
? "Protocol upgrade required; destination availability not verified"
|
|
1200
|
+
: headStatus === 428
|
|
1201
|
+
? "Precondition required; destination availability not verified"
|
|
1202
|
+
: headStatus === 429
|
|
1203
|
+
? "Rate limited; destination availability not verified"
|
|
1204
|
+
: headStatus === 431
|
|
1205
|
+
? "Request headers too large; destination availability not verified"
|
|
1206
|
+
: headStatus === 451
|
|
1207
|
+
? "Unavailable for legal reasons; destination availability not verified"
|
|
1208
|
+
: headStatus === 502 || headStatus === 503 || headStatus === 504 || (headStatus >= 520 && headStatus <= 524)
|
|
1209
|
+
? "Temporary gateway or service failure; destination availability not verified"
|
|
1210
|
+
: headStatus === 511
|
|
1211
|
+
? "Network authentication required; destination availability not verified"
|
|
1212
|
+
: headStatus === 525
|
|
1213
|
+
? "Cloudflare TLS handshake with origin failed; destination unavailable"
|
|
1214
|
+
: headStatus === 526
|
|
1215
|
+
? "Cloudflare could not validate origin TLS certificate; destination unavailable"
|
|
1216
|
+
: isUnverifiedServerError(headStatus)
|
|
1217
|
+
? "Server error; destination availability not verified"
|
|
1218
|
+
: isHttpRedirectStatus(headStatus)
|
|
1219
|
+
? "Redirect not followed"
|
|
1220
|
+
: headFinalUrl !== url
|
|
1221
|
+
? `Redirected to ${headFinalUrl}`
|
|
1222
|
+
: undefined,
|
|
913
1223
|
};
|
|
914
1224
|
}
|
|
915
1225
|
catch (error) {
|