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,557 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V05 bounded sitemap inventory and indexability cross-checks.
|
|
3
|
+
* No network, crawler identity, storage or source URLs in the output.
|
|
4
|
+
* XML input is parsed strictly enough to reject malformed structures and
|
|
5
|
+
* never expands external entities. Full-site coverage is never inferred
|
|
6
|
+
* unless the caller supplies a complete document/crawl inventory.
|
|
7
|
+
*/
|
|
8
|
+
import { load } from "cheerio";
|
|
9
|
+
import { safeVariantLabel } from "./url-variants.js";
|
|
10
|
+
export const MAX_SITEMAP_DOCUMENTS = 8;
|
|
11
|
+
export const MAX_SITEMAP_DOCUMENT_BYTES = 512_000;
|
|
12
|
+
export const MAX_SITEMAP_TOTAL_BYTES = 1_500_000;
|
|
13
|
+
export const MAX_SITEMAP_URLS = 2_000;
|
|
14
|
+
export const MAX_SITEMAP_DISCOVERED = 500;
|
|
15
|
+
export const MAX_SITEMAP_PAGE_OBSERVATIONS = 250;
|
|
16
|
+
export const MAX_SITEMAP_FINDINGS = 32;
|
|
17
|
+
export const MAX_SITEMAP_URL_BYTES = 2_048;
|
|
18
|
+
const SITEMAP_NS = "http://www.sitemaps.org/schemas/sitemap/0.9";
|
|
19
|
+
const enc = new TextEncoder();
|
|
20
|
+
export const SITEMAP_DOCUMENT_KINDS = [
|
|
21
|
+
"urlset", "sitemapindex", "text", "invalid", "unsupported",
|
|
22
|
+
];
|
|
23
|
+
export const SITEMAP_FINDING_CODES = [
|
|
24
|
+
"sitemap_http_error", "xml_malformed", "unsupported_format",
|
|
25
|
+
"missing_loc", "invalid_loc", "external_loc", "out_of_scope_loc",
|
|
26
|
+
"duplicate_loc", "invalid_lastmod", "future_lastmod",
|
|
27
|
+
"conflicting_lastmod", "lastmod_vs_observed_change",
|
|
28
|
+
"sitemap_child_missing", "sitemap_unlisted_child",
|
|
29
|
+
"sitemap_cycle", "sitemap_inventory_truncated",
|
|
30
|
+
"sitemap_page_not_discovered", "discovered_page_not_sitemapped",
|
|
31
|
+
"sitemap_url_http_error", "sitemap_url_redirect",
|
|
32
|
+
"sitemap_url_noindex", "sitemap_url_robots_blocked",
|
|
33
|
+
"sitemap_url_noncanonical", "observed_page_not_in_sitemap",
|
|
34
|
+
"unverified_indexability", "unverified_coverage",
|
|
35
|
+
];
|
|
36
|
+
const limits = [
|
|
37
|
+
"Bounded sitemap documents are samples, not proof of complete site inventory, crawl coverage or Google indexing.",
|
|
38
|
+
"Sitemap inclusion recommends canonical discovery; actual crawl/index selection and historical fetches are not verified.",
|
|
39
|
+
"Date conflicts depend on caller-supplied independent modification evidence; equal dates alone are not incorrect.",
|
|
40
|
+
"Only XML urlset/index and plain-text sitemap entries are assessed here; RSS/Atom feeds require a separate export.",
|
|
41
|
+
];
|
|
42
|
+
function bytes(v) { return enc.encode(v).byteLength; }
|
|
43
|
+
function safeUrl(value, allowQuery = true) {
|
|
44
|
+
if (typeof value !== "string" || !value || bytes(value) > MAX_SITEMAP_URL_BYTES ||
|
|
45
|
+
/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069\\]/u.test(value) ||
|
|
46
|
+
value.includes("#"))
|
|
47
|
+
return undefined;
|
|
48
|
+
const parsed = safeVariantLabel(value);
|
|
49
|
+
if (!parsed)
|
|
50
|
+
return undefined;
|
|
51
|
+
const url = new URL(parsed);
|
|
52
|
+
if (!allowQuery && (url.search || value.includes("?")))
|
|
53
|
+
return undefined;
|
|
54
|
+
return url;
|
|
55
|
+
}
|
|
56
|
+
function strictDate(value) {
|
|
57
|
+
if (typeof value !== "string" || value.length < 10 || value.length > 40)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (!/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2}))?$/u.test(value)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const year = Number(value.slice(0, 4));
|
|
63
|
+
const month = Number(value.slice(5, 7));
|
|
64
|
+
const day = Number(value.slice(8, 10));
|
|
65
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
66
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
67
|
+
if (!year || month < 1 || month > 12 || day < 1 || day > days[month - 1])
|
|
68
|
+
return undefined;
|
|
69
|
+
const parsed = Date.parse(value);
|
|
70
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
71
|
+
}
|
|
72
|
+
/** The first safe same-origin robots.txt Sitemap declaration, if present. */
|
|
73
|
+
export function sitemapFromRobotsTxt(siteUrl, robotsText) {
|
|
74
|
+
const site = safeUrl(siteUrl, false);
|
|
75
|
+
if (!site || typeof robotsText !== "string" || bytes(robotsText) > 64_000)
|
|
76
|
+
return undefined;
|
|
77
|
+
for (const line of robotsText.split(/\r\n|\r|\n/u)) {
|
|
78
|
+
const match = /^\s*sitemap\s*:\s*(\S+)(?:\s+#.*)?\s*$/iu.exec(line);
|
|
79
|
+
if (!match)
|
|
80
|
+
continue;
|
|
81
|
+
const found = safeUrl(match[1], false);
|
|
82
|
+
if (found && found.origin === site.origin)
|
|
83
|
+
return found.href;
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Bounded XML well-formedness gate, independent of Cheerio recovery.
|
|
89
|
+
* Rejects DTD/entity declarations, unescaped entities, bad quoted attributes,
|
|
90
|
+
* nesting errors, extra roots and unbound-prefixed element names.
|
|
91
|
+
*/
|
|
92
|
+
function isWellFormedXml(source) {
|
|
93
|
+
if (/<!\s*(?:DOCTYPE|ENTITY)/iu.test(source))
|
|
94
|
+
return false;
|
|
95
|
+
const stack = [];
|
|
96
|
+
const bindings = [];
|
|
97
|
+
let cursor = 0;
|
|
98
|
+
let roots = 0;
|
|
99
|
+
const nameRx = /^[A-Za-z_][A-Za-z0-9_.:-]*$/u;
|
|
100
|
+
function entitiesValid(text) {
|
|
101
|
+
const re = /&(?:amp|lt|gt|apos|quot|#(?:[0-9]{1,8}|x[0-9a-fA-F]{1,6}));/gu;
|
|
102
|
+
const without = text.replace(re, "");
|
|
103
|
+
return !without.includes("&");
|
|
104
|
+
}
|
|
105
|
+
while (cursor < source.length) {
|
|
106
|
+
const start = source.indexOf("<", cursor);
|
|
107
|
+
if (start < 0) {
|
|
108
|
+
const remaining = source.slice(cursor);
|
|
109
|
+
return (stack.length > 0 || remaining.trim() === "") && entitiesValid(remaining)
|
|
110
|
+
&& stack.length === 0 && roots === 1;
|
|
111
|
+
}
|
|
112
|
+
const plain = source.slice(cursor, start);
|
|
113
|
+
if ((!stack.length && plain.trim()) || plain.includes("]]>") || !entitiesValid(plain))
|
|
114
|
+
return false;
|
|
115
|
+
if (source.startsWith("<!--", start)) {
|
|
116
|
+
const end = source.indexOf("-->", start + 4);
|
|
117
|
+
if (end < 0 || source.slice(start + 4, end).includes("--"))
|
|
118
|
+
return false;
|
|
119
|
+
cursor = end + 3;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (source.startsWith("<![CDATA[", start)) {
|
|
123
|
+
if (!stack.length)
|
|
124
|
+
return false;
|
|
125
|
+
const end = source.indexOf("]]>", start + 9);
|
|
126
|
+
if (end < 0)
|
|
127
|
+
return false;
|
|
128
|
+
cursor = end + 3;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (source.startsWith("<?", start)) {
|
|
132
|
+
const end = source.indexOf("?>", start + 2);
|
|
133
|
+
if (end < 0 || source.slice(start + 2, end).includes("<"))
|
|
134
|
+
return false;
|
|
135
|
+
cursor = end + 2;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (source.startsWith("<!", start))
|
|
139
|
+
return false;
|
|
140
|
+
let end = start + 1;
|
|
141
|
+
let quote = "";
|
|
142
|
+
for (; end < source.length; end++) {
|
|
143
|
+
const c = source[end];
|
|
144
|
+
if (quote) {
|
|
145
|
+
if (c === "<")
|
|
146
|
+
return false;
|
|
147
|
+
if (c === quote)
|
|
148
|
+
quote = "";
|
|
149
|
+
}
|
|
150
|
+
else if (c === '"' || c === "'")
|
|
151
|
+
quote = c;
|
|
152
|
+
else if (c === "<")
|
|
153
|
+
return false;
|
|
154
|
+
else if (c === ">")
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (end === source.length || quote)
|
|
158
|
+
return false;
|
|
159
|
+
let tag = source.slice(start + 1, end).trim();
|
|
160
|
+
if (tag.startsWith("/")) {
|
|
161
|
+
const name = tag.slice(1).trim();
|
|
162
|
+
if (!nameRx.test(name) || stack.pop() !== name)
|
|
163
|
+
return false;
|
|
164
|
+
bindings.pop();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const self = tag.endsWith("/");
|
|
168
|
+
if (self)
|
|
169
|
+
tag = tag.slice(0, -1).trimEnd();
|
|
170
|
+
const first = /^([^\s]+)([\s\S]*)$/u.exec(tag);
|
|
171
|
+
if (!first || !nameRx.test(first[1]))
|
|
172
|
+
return false;
|
|
173
|
+
let attrs = first[2];
|
|
174
|
+
const seen = new Set();
|
|
175
|
+
const scope = new Set(bindings.at(-1) ?? ["xml"]);
|
|
176
|
+
while (attrs.trim()) {
|
|
177
|
+
const a = /^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/u.exec(attrs);
|
|
178
|
+
if (!a || seen.has(a[1]) || !entitiesValid(a[2] ?? a[3]))
|
|
179
|
+
return false;
|
|
180
|
+
seen.add(a[1]);
|
|
181
|
+
if (a[1].startsWith("xmlns:"))
|
|
182
|
+
scope.add(a[1].slice(6));
|
|
183
|
+
attrs = attrs.slice(a[0].length);
|
|
184
|
+
}
|
|
185
|
+
const prefix = first[1].includes(":") ? first[1].split(":")[0] : undefined;
|
|
186
|
+
if (prefix && !scope.has(prefix))
|
|
187
|
+
return false;
|
|
188
|
+
if (!stack.length && ++roots > 1)
|
|
189
|
+
return false;
|
|
190
|
+
if (!self) {
|
|
191
|
+
stack.push(first[1]);
|
|
192
|
+
bindings.push(scope);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
cursor = end + 1;
|
|
196
|
+
}
|
|
197
|
+
return stack.length === 0 && roots === 1;
|
|
198
|
+
}
|
|
199
|
+
export function emptySitemapInventoryReview(scope = "caller_supplied_sitemap_evidence") {
|
|
200
|
+
return {
|
|
201
|
+
scope, documents_observed: 0, documents_complete: false,
|
|
202
|
+
discovered_complete: false, inventory_complete: false,
|
|
203
|
+
documents_truncated: false, total_entries_seen: 0,
|
|
204
|
+
distinct_sitemap_urls: 0, distinct_page_urls: 0,
|
|
205
|
+
distinct_child_sitemaps: 0, missing_child_documents: 0,
|
|
206
|
+
duplicate_url_entries: 0, invalid_url_entries: 0,
|
|
207
|
+
external_url_entries: 0, lastmod_values_seen: 0,
|
|
208
|
+
lastmod_invalid_count: 0, lastmod_future_count: 0,
|
|
209
|
+
lastmod_conflicting_count: 0, independently_discovered_urls: 0,
|
|
210
|
+
discovered_in_sitemaps: 0, discovered_missing_from_sitemaps: 0,
|
|
211
|
+
sitemap_urls_not_in_discovery: 0, page_observations: 0,
|
|
212
|
+
sitemap_urls_with_page_evidence: 0, status_conflicts: 0,
|
|
213
|
+
noindex_conflicts: 0, robots_conflicts: 0,
|
|
214
|
+
canonical_conflicts: 0, lastmod_observation_conflicts: 0,
|
|
215
|
+
known_indexability_conflicts: 0, unknown_page_indexability: 0,
|
|
216
|
+
coverage_limited: true, limitations: limits, documents: [],
|
|
217
|
+
total_findings: 0, findings: [], findings_truncated: false,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export function analyzeSitemapInventory(input, scope = "caller_supplied_sitemap_evidence") {
|
|
221
|
+
const site = safeUrl(input?.site_url, false);
|
|
222
|
+
if (!site || !Array.isArray(input.documents) ||
|
|
223
|
+
input.documents.length < 1 || input.documents.length > MAX_SITEMAP_DOCUMENTS) {
|
|
224
|
+
throw new Error("Supply a safe site URL and one to eight observed sitemap documents.");
|
|
225
|
+
}
|
|
226
|
+
const documents = input.documents;
|
|
227
|
+
const discovered = input.discovered_urls ?? [];
|
|
228
|
+
const pages = input.page_observations ?? [];
|
|
229
|
+
if (!Array.isArray(discovered) || discovered.length > MAX_SITEMAP_DISCOVERED ||
|
|
230
|
+
!Array.isArray(pages) || pages.length > MAX_SITEMAP_PAGE_OBSERVATIONS ||
|
|
231
|
+
(input.documents_complete !== undefined && typeof input.documents_complete !== "boolean") ||
|
|
232
|
+
(input.discovered_complete !== undefined && typeof input.discovered_complete !== "boolean")) {
|
|
233
|
+
throw new Error("Sitemap coverage observations exceed bounds.");
|
|
234
|
+
}
|
|
235
|
+
const now = input.observed_at === undefined ? Date.now() : strictDate(input.observed_at);
|
|
236
|
+
if (now === undefined)
|
|
237
|
+
throw new Error("Observed clock must be a real ISO date.");
|
|
238
|
+
const out = emptySitemapInventoryReview(scope);
|
|
239
|
+
out.documents_observed = documents.length;
|
|
240
|
+
out.documents_complete = input.documents_complete === true;
|
|
241
|
+
out.discovered_complete = input.discovered_complete === true;
|
|
242
|
+
function finding(document, code, severity, message, entry) {
|
|
243
|
+
out.total_findings++;
|
|
244
|
+
if (out.findings.length < MAX_SITEMAP_FINDINGS)
|
|
245
|
+
out.findings.push({
|
|
246
|
+
document, code, severity, message, ...(entry ? { entry } : {}),
|
|
247
|
+
});
|
|
248
|
+
else
|
|
249
|
+
out.findings_truncated = true;
|
|
250
|
+
}
|
|
251
|
+
const observedDocuments = new Set();
|
|
252
|
+
let totalBytes = 0;
|
|
253
|
+
const allPages = new Map();
|
|
254
|
+
const allChildren = new Map();
|
|
255
|
+
const allDocumentResults = [];
|
|
256
|
+
const dateByPage = new Map();
|
|
257
|
+
for (let docIdx = 0; docIdx < documents.length; docIdx++) {
|
|
258
|
+
const doc = documents[docIdx];
|
|
259
|
+
if (!doc || typeof doc.content !== "string" ||
|
|
260
|
+
bytes(doc.content) > MAX_SITEMAP_DOCUMENT_BYTES) {
|
|
261
|
+
throw new Error("Sitemap content must be bounded UTF-8 text.");
|
|
262
|
+
}
|
|
263
|
+
totalBytes += bytes(doc.content);
|
|
264
|
+
if (totalBytes > MAX_SITEMAP_TOTAL_BYTES) {
|
|
265
|
+
throw new Error("Combined sitemap content exceeded the total limit.");
|
|
266
|
+
}
|
|
267
|
+
const label = safeUrl(doc.sitemap_url, false);
|
|
268
|
+
if (!label || label.origin !== site.origin || observedDocuments.has(label.href)) {
|
|
269
|
+
throw new Error("Each supplied sitemap URL must be unique, same-origin and query-free.");
|
|
270
|
+
}
|
|
271
|
+
observedDocuments.add(label.href);
|
|
272
|
+
const status = doc.status_code;
|
|
273
|
+
if (status !== undefined && (!Number.isInteger(status) || status < 100 || status > 599)) {
|
|
274
|
+
throw new Error("Invalid sitemap HTTP status.");
|
|
275
|
+
}
|
|
276
|
+
const contentType = doc.content_type ?? "application/xml";
|
|
277
|
+
if (!["application/xml", "text/xml", "text/plain"].includes(contentType)) {
|
|
278
|
+
throw new Error("Unsupported content-type field.");
|
|
279
|
+
}
|
|
280
|
+
const report = {
|
|
281
|
+
document: docIdx + 1, kind: "invalid",
|
|
282
|
+
...(status === undefined ? {} : { status_code: status }),
|
|
283
|
+
entries_seen: 0, valid_url_entries: 0, child_sitemaps: 0,
|
|
284
|
+
invalid_entries: 0, external_entries: 0, duplicate_entries: 0,
|
|
285
|
+
lastmod_present: 0, lastmod_invalid: 0, lastmod_future: 0,
|
|
286
|
+
truncated: false,
|
|
287
|
+
};
|
|
288
|
+
const result = { report, entries: [], children: [], rootUrl: label };
|
|
289
|
+
allDocumentResults.push(result);
|
|
290
|
+
out.documents.push(report);
|
|
291
|
+
if (status !== undefined && !(status >= 200 && status < 300)) {
|
|
292
|
+
finding(docIdx + 1, "sitemap_http_error", "warning", "The supplied sitemap URL returned a non-2xx HTTP status.");
|
|
293
|
+
report.kind = "invalid";
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
let entries = [];
|
|
297
|
+
if (contentType === "text/plain") {
|
|
298
|
+
report.kind = "text";
|
|
299
|
+
entries = doc.content.split(/\r\n|\n|\r/u).map((value) => ({ value: value.trim(), child: false })).filter((row) => row.value.length > 0);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
if (!isWellFormedXml(doc.content)) {
|
|
303
|
+
finding(docIdx + 1, "xml_malformed", "warning", "The supplied sitemap XML has malformed elements, declarations or entities.");
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const $ = load(doc.content, { xmlMode: true });
|
|
308
|
+
const root = $.root().children().first();
|
|
309
|
+
const rootName = root.get(0)?.name ?? "";
|
|
310
|
+
const localName = rootName.slice(rootName.indexOf(":") + 1);
|
|
311
|
+
const prefix = rootName.includes(":") ? rootName.split(":")[0] : "";
|
|
312
|
+
const ns = root.attr(prefix ? "xmlns:" + prefix : "xmlns");
|
|
313
|
+
if (!["urlset", "sitemapindex"].includes(localName) ||
|
|
314
|
+
(ns !== SITEMAP_NS && ns !== undefined)) {
|
|
315
|
+
report.kind = "unsupported";
|
|
316
|
+
finding(docIdx + 1, "unsupported_format", "warning", "Only standard XML urlsets/indexes and plain-text sitemap documents are supported.");
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
report.kind = localName;
|
|
320
|
+
const tag = localName === "urlset" ? "url" : "sitemap";
|
|
321
|
+
const childMode = localName === "sitemapindex";
|
|
322
|
+
root.children().each((_i, item) => {
|
|
323
|
+
if (item.type !== "tag" || item.name !== (prefix ? prefix + ":" + tag : tag))
|
|
324
|
+
return;
|
|
325
|
+
const element = $(item);
|
|
326
|
+
const loc = element.children().filter((_j, node) => node.type === "tag" && node.name === (prefix ? prefix + ":loc" : "loc"));
|
|
327
|
+
const lastmod = element.children().filter((_j, node) => node.type === "tag" && node.name === (prefix ? prefix + ":lastmod" : "lastmod"));
|
|
328
|
+
entries.push({
|
|
329
|
+
value: loc.length === 1 ? loc.text().trim() : "",
|
|
330
|
+
...(lastmod.length === 1 ? { lastmod: lastmod.text().trim() } :
|
|
331
|
+
lastmod.length > 1 ? { lastmod: "" } : {}),
|
|
332
|
+
child: childMode,
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
report.kind = "invalid";
|
|
338
|
+
finding(docIdx + 1, "xml_malformed", "warning", "The sitemap XML could not be parsed safely.");
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const inDocument = new Set();
|
|
343
|
+
for (let i = 0; i < entries.length; i++) {
|
|
344
|
+
if (out.total_entries_seen >= MAX_SITEMAP_URLS) {
|
|
345
|
+
report.truncated = true;
|
|
346
|
+
out.documents_truncated = true;
|
|
347
|
+
finding(docIdx + 1, "sitemap_inventory_truncated", "info", "The bounded URL entry limit was reached; remaining entries were not counted.");
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
report.entries_seen++;
|
|
351
|
+
out.total_entries_seen++;
|
|
352
|
+
const entry = entries[i];
|
|
353
|
+
const pageUrl = safeUrl(entry.value, !entry.child);
|
|
354
|
+
if (!pageUrl) {
|
|
355
|
+
report.invalid_entries++;
|
|
356
|
+
out.invalid_url_entries++;
|
|
357
|
+
finding(docIdx + 1, entry.value ? "invalid_loc" : "missing_loc", "warning", "A sitemap entry has a missing, relative, malformed or unsupported URL.", i + 1);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (pageUrl.origin !== site.origin) {
|
|
361
|
+
report.external_entries++;
|
|
362
|
+
out.external_url_entries++;
|
|
363
|
+
finding(docIdx + 1, "external_loc", "info", "A sitemap entry points outside the target site; cross-site authorization was not verified.", i + 1);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (entry.child && !pageUrl.pathname.startsWith(label.pathname.slice(0, label.pathname.lastIndexOf("/") + 1))) {
|
|
367
|
+
finding(docIdx + 1, "out_of_scope_loc", "info", "A child sitemap is outside its index directory; cross-directory submission may need verification.", i + 1);
|
|
368
|
+
}
|
|
369
|
+
const store = entry.child ? allChildren : allPages;
|
|
370
|
+
const repeatedHere = inDocument.has(pageUrl.href);
|
|
371
|
+
const repeatedElsewhere = !repeatedHere && store.has(pageUrl.href);
|
|
372
|
+
if (repeatedHere || repeatedElsewhere) {
|
|
373
|
+
report.duplicate_entries++;
|
|
374
|
+
out.duplicate_url_entries++;
|
|
375
|
+
finding(docIdx + 1, "duplicate_loc", "info", repeatedHere
|
|
376
|
+
? "A URL is repeated within the same sitemap document."
|
|
377
|
+
: "This URL also appeared in another supplied sitemap document.", i + 1);
|
|
378
|
+
}
|
|
379
|
+
inDocument.add(pageUrl.href);
|
|
380
|
+
let lastmod;
|
|
381
|
+
let lastmodValid = true;
|
|
382
|
+
if (entry.lastmod !== undefined) {
|
|
383
|
+
report.lastmod_present++;
|
|
384
|
+
out.lastmod_values_seen++;
|
|
385
|
+
lastmod = strictDate(entry.lastmod);
|
|
386
|
+
if (lastmod === undefined) {
|
|
387
|
+
lastmodValid = false;
|
|
388
|
+
report.lastmod_invalid++;
|
|
389
|
+
out.lastmod_invalid_count++;
|
|
390
|
+
finding(docIdx + 1, "invalid_lastmod", "warning", "A sitemap lastmod is not a valid W3C date/datetime.", i + 1);
|
|
391
|
+
}
|
|
392
|
+
else if (lastmod > now + 24 * 60 * 60 * 1000) {
|
|
393
|
+
report.lastmod_future++;
|
|
394
|
+
out.lastmod_future_count++;
|
|
395
|
+
finding(docIdx + 1, "future_lastmod", "warning", "A sitemap lastmod is more than a day in the future relative to the observation clock.", i + 1);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const found = { url: pageUrl, document: docIdx + 1,
|
|
399
|
+
entry: i + 1, lastmod, lastmodValid };
|
|
400
|
+
store.set(pageUrl.href, store.get(pageUrl.href) ?? found);
|
|
401
|
+
(entry.child ? result.children : result.entries).push(found);
|
|
402
|
+
if (entry.child)
|
|
403
|
+
report.child_sitemaps++;
|
|
404
|
+
else
|
|
405
|
+
report.valid_url_entries++;
|
|
406
|
+
if (lastmod !== undefined && !entry.child) {
|
|
407
|
+
const earlier = dateByPage.get(pageUrl.href);
|
|
408
|
+
if (earlier !== undefined && earlier !== lastmod) {
|
|
409
|
+
out.lastmod_conflicting_count++;
|
|
410
|
+
finding(docIdx + 1, "conflicting_lastmod", "warning", "The same URL has different lastmod dates across observed sitemap entries.", i + 1);
|
|
411
|
+
}
|
|
412
|
+
dateByPage.set(pageUrl.href, lastmod);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
out.distinct_page_urls = allPages.size;
|
|
417
|
+
out.distinct_sitemap_urls = observedDocuments.size;
|
|
418
|
+
out.distinct_child_sitemaps = allChildren.size;
|
|
419
|
+
for (const child of allChildren.values()) {
|
|
420
|
+
if (!observedDocuments.has(child.url.href)) {
|
|
421
|
+
out.missing_child_documents++;
|
|
422
|
+
finding(child.document, "sitemap_child_missing", "info", "An index references a child sitemap that was not supplied or fetched.", child.entry);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
out.inventory_complete = out.documents_complete &&
|
|
426
|
+
!out.documents_truncated && out.missing_child_documents === 0 &&
|
|
427
|
+
out.documents.every((doc) => doc.kind !== "invalid" && doc.kind !== "unsupported");
|
|
428
|
+
if (input.documents_complete === true && out.missing_child_documents > 0) {
|
|
429
|
+
out.inventory_complete = false;
|
|
430
|
+
}
|
|
431
|
+
const uniqueDiscovered = new Set();
|
|
432
|
+
for (const value of discovered) {
|
|
433
|
+
const url = safeUrl(value);
|
|
434
|
+
if (!url || url.origin !== site.origin)
|
|
435
|
+
throw new Error("Discovered URL labels must be same-origin safe URLs.");
|
|
436
|
+
uniqueDiscovered.add(url.href);
|
|
437
|
+
}
|
|
438
|
+
out.independently_discovered_urls = uniqueDiscovered.size;
|
|
439
|
+
for (const value of uniqueDiscovered) {
|
|
440
|
+
if (allPages.has(value))
|
|
441
|
+
out.discovered_in_sitemaps++;
|
|
442
|
+
else {
|
|
443
|
+
out.discovered_missing_from_sitemaps++;
|
|
444
|
+
finding(0, "discovered_page_not_sitemapped", "info", "A caller-discovered page does not appear in the supplied sitemap URLs.");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
for (const url of allPages.keys()) {
|
|
448
|
+
if (!uniqueDiscovered.has(url) && discovered.length) {
|
|
449
|
+
out.sitemap_urls_not_in_discovery++;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (!out.inventory_complete || !out.discovered_complete) {
|
|
453
|
+
finding(0, "unverified_coverage", "info", "No complete independent sitemap-and-discovery inventory is proven by these samples.");
|
|
454
|
+
}
|
|
455
|
+
const seenPageObservations = new Set();
|
|
456
|
+
for (const observed of pages) {
|
|
457
|
+
if (!observed || typeof observed !== "object") {
|
|
458
|
+
throw new Error("Invalid page observation.");
|
|
459
|
+
}
|
|
460
|
+
const pageUrl = safeUrl(observed.url);
|
|
461
|
+
if (!pageUrl || pageUrl.origin !== site.origin ||
|
|
462
|
+
seenPageObservations.has(pageUrl.href) ||
|
|
463
|
+
(observed.status_code !== undefined &&
|
|
464
|
+
(!Number.isInteger(observed.status_code) ||
|
|
465
|
+
observed.status_code < 100 || observed.status_code > 599)) ||
|
|
466
|
+
(observed.noindex !== undefined && typeof observed.noindex !== "boolean") ||
|
|
467
|
+
(observed.robots_allowed !== undefined && typeof observed.robots_allowed !== "boolean")) {
|
|
468
|
+
throw new Error("Page observations must be distinct safe same-origin records.");
|
|
469
|
+
}
|
|
470
|
+
seenPageObservations.add(pageUrl.href);
|
|
471
|
+
const canonical = observed.canonical_url === undefined ? undefined : safeUrl(observed.canonical_url);
|
|
472
|
+
if (observed.canonical_url !== undefined && !canonical) {
|
|
473
|
+
throw new Error("Invalid observed canonical label.");
|
|
474
|
+
}
|
|
475
|
+
const modified = observed.modified_at === undefined ? undefined : strictDate(observed.modified_at);
|
|
476
|
+
if (observed.modified_at !== undefined && modified === undefined) {
|
|
477
|
+
throw new Error("Invalid independent modification timestamp.");
|
|
478
|
+
}
|
|
479
|
+
out.page_observations++;
|
|
480
|
+
const listed = allPages.get(pageUrl.href);
|
|
481
|
+
if (!listed) {
|
|
482
|
+
finding(0, "observed_page_not_in_sitemap", "info", "An observed page is not among the supplied sitemap URL records.");
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
out.sitemap_urls_with_page_evidence++;
|
|
486
|
+
let conflicting = false;
|
|
487
|
+
if (observed.status_code !== undefined) {
|
|
488
|
+
if ([301, 302, 303, 307, 308].includes(observed.status_code)) {
|
|
489
|
+
out.status_conflicts++;
|
|
490
|
+
conflicting = true;
|
|
491
|
+
finding(listed.document, "sitemap_url_redirect", "warning", "A sitemap-listed page returned a redirect instead of a direct 2xx response.", listed.entry);
|
|
492
|
+
}
|
|
493
|
+
else if (observed.status_code < 200 || observed.status_code >= 400) {
|
|
494
|
+
out.status_conflicts++;
|
|
495
|
+
conflicting = true;
|
|
496
|
+
finding(listed.document, "sitemap_url_http_error", "warning", "A sitemap-listed page returned a non-indexable HTTP error or non-2xx state.", listed.entry);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (observed.noindex === true) {
|
|
500
|
+
out.noindex_conflicts++;
|
|
501
|
+
conflicting = true;
|
|
502
|
+
finding(listed.document, "sitemap_url_noindex", "warning", "A sitemap-listed page has an independently observed noindex declaration.", listed.entry);
|
|
503
|
+
}
|
|
504
|
+
if (observed.robots_allowed === false) {
|
|
505
|
+
out.robots_conflicts++;
|
|
506
|
+
conflicting = true;
|
|
507
|
+
finding(listed.document, "sitemap_url_robots_blocked", "warning", "A sitemap-listed page is marked robots-disallowed in supplied evidence.", listed.entry);
|
|
508
|
+
}
|
|
509
|
+
if (canonical && canonical.href !== pageUrl.href) {
|
|
510
|
+
out.canonical_conflicts++;
|
|
511
|
+
conflicting = true;
|
|
512
|
+
finding(listed.document, "sitemap_url_noncanonical", "warning", "A sitemap-listed page declares a different preferred canonical URL.", listed.entry);
|
|
513
|
+
}
|
|
514
|
+
if (modified !== undefined && listed.lastmod !== undefined &&
|
|
515
|
+
Math.abs(modified - listed.lastmod) > 24 * 60 * 60 * 1000) {
|
|
516
|
+
out.lastmod_observation_conflicts++;
|
|
517
|
+
finding(listed.document, "lastmod_vs_observed_change", "info", "The sitemap lastmod differs from independently supplied significant modification time.", listed.entry);
|
|
518
|
+
}
|
|
519
|
+
if (conflicting)
|
|
520
|
+
out.known_indexability_conflicts++;
|
|
521
|
+
if (observed.status_code === undefined || observed.noindex === undefined ||
|
|
522
|
+
observed.robots_allowed === undefined || canonical === undefined) {
|
|
523
|
+
out.unknown_page_indexability++;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
out.coverage_limited = true;
|
|
527
|
+
return out;
|
|
528
|
+
}
|
|
529
|
+
/** Simple first-party accessor for live indexing of bounded child sitemap links. */
|
|
530
|
+
export function sitemapIndexChildUrls(input) {
|
|
531
|
+
const review = analyzeSitemapInventory(input);
|
|
532
|
+
if (review.documents_truncated)
|
|
533
|
+
return [];
|
|
534
|
+
const found = [];
|
|
535
|
+
for (const doc of input.documents) {
|
|
536
|
+
const safe = safeUrl(doc.sitemap_url, false);
|
|
537
|
+
if (!safe || !isWellFormedXml(doc.content))
|
|
538
|
+
continue;
|
|
539
|
+
const $ = load(doc.content, { xmlMode: true });
|
|
540
|
+
const root = $.root().children().first();
|
|
541
|
+
const rootName = root.get(0)?.name ?? "";
|
|
542
|
+
if (!rootName.endsWith("sitemapindex"))
|
|
543
|
+
continue;
|
|
544
|
+
const prefix = rootName.includes(":") ? rootName.split(":")[0] : "";
|
|
545
|
+
root.children().each((_i, el) => {
|
|
546
|
+
if (el.type !== "tag" || el.name !== (prefix ? prefix + ":sitemap" : "sitemap"))
|
|
547
|
+
return;
|
|
548
|
+
const text = $(el).children().filter((_j, node) => node.type === "tag" && node.name === (prefix ? prefix + ":loc" : "loc")).text().trim();
|
|
549
|
+
const candidate = safeUrl(text, false);
|
|
550
|
+
if (candidate && candidate.origin === safe.origin &&
|
|
551
|
+
!found.includes(candidate.href))
|
|
552
|
+
found.push(candidate.href);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return found.slice(0, 3);
|
|
556
|
+
}
|
|
557
|
+
//# sourceMappingURL=sitemap-inventory.js.map
|