@duffcloudservices/cms 0.13.8 → 0.13.9

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.
@@ -1398,6 +1398,42 @@ var BodyPrerenderError = class extends Error {
1398
1398
  this.errors = errors;
1399
1399
  }
1400
1400
  };
1401
+ var ATTR_RE = /\s([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
1402
+ function readAttrs(tag) {
1403
+ const attrs = /* @__PURE__ */ new Map();
1404
+ const inner = tag.replace(/^<[a-zA-Z][^\s/>]*/, "").replace(/\/?>$/, "");
1405
+ ATTR_RE.lastIndex = 0;
1406
+ let m;
1407
+ while ((m = ATTR_RE.exec(inner)) !== null) {
1408
+ const name = m[1].toLowerCase();
1409
+ if (!attrs.has(name)) attrs.set(name, m[2] ?? m[3] ?? m[4] ?? "");
1410
+ }
1411
+ return attrs;
1412
+ }
1413
+ function disablePrehydrationSubmit(html) {
1414
+ if (!html.includes("dcs-form")) return html;
1415
+ const formOpenRe = /<form\b[^>]*>/gi;
1416
+ let out = "";
1417
+ let cursor = 0;
1418
+ let m;
1419
+ while ((m = formOpenRe.exec(html)) !== null) {
1420
+ const classes = (readAttrs(m[0]).get("class") ?? "").split(/\s+/);
1421
+ if (!classes.includes("dcs-form")) continue;
1422
+ const start = m.index + m[0].length;
1423
+ const closeIdx = html.toLowerCase().indexOf("</form", start);
1424
+ const end = closeIdx === -1 ? html.length : closeIdx;
1425
+ const inner = html.slice(start, end).replace(/<button\b[^>]*>/gi, (tag) => {
1426
+ const attrs = readAttrs(tag);
1427
+ if ((attrs.get("type") ?? "").toLowerCase() !== "submit") return tag;
1428
+ if (attrs.has("disabled")) return tag;
1429
+ return tag.replace(/\s*(\/?)>$/, (_close, slash) => ` disabled=""${slash}>`);
1430
+ });
1431
+ out += html.slice(cursor, start) + inner;
1432
+ cursor = end;
1433
+ formOpenRe.lastIndex = end;
1434
+ }
1435
+ return cursor === 0 ? html : out + html.slice(cursor);
1436
+ }
1401
1437
  function spliceBodyHtml(html, bodyInnerHtml) {
1402
1438
  const openRe = /<div\s+[^>]*\bid=["']app["'][^>]*>/i;
1403
1439
  const openMatch = openRe.exec(html);
@@ -1484,7 +1520,7 @@ async function prerenderBodies(params) {
1484
1520
  runtimeDescriptionCount: rendered.head.descriptionCount
1485
1521
  });
1486
1522
  }
1487
- const body = (rendered.bodyHtml ?? "").trim();
1523
+ const body = disablePrehydrationSubmit((rendered.bodyHtml ?? "").trim());
1488
1524
  if (body === "") {
1489
1525
  skipped += 1;
1490
1526
  if (debug) console.log(`[dcs-seo] body-prerender skip (empty render): ${route.path}`);
@@ -2219,5 +2255,5 @@ function createSeoTransformPageData(options) {
2219
2255
  }
2220
2256
 
2221
2257
  export { AI_BOTS, BodyPrerenderError, CANONICAL_CHARSET_META, CHARSET_BUDGET_BYTES, CHARSET_HEADROOM_WARN_BYTES, CharsetBudgetError, EmittedUrlError, EmittedUrlNotRunError, HeadHonestyError, HeadHonestyNotRunError, REQUIRED_POSTAL_ADDRESS_FIELDS, SEO_HEAD_ROUTE_HAS_NO_META, absolutizeUrl, assertHeadHonesty, assertHeadHonestyExecuted, auditCheckedTotal, auditSameOriginAssets, breadcrumbTrailFromRoute, buildBlogPosting, buildBreadcrumbList, buildFaqPage, buildGlobalGraph, buildHasCredential, buildHeadTags, buildLlmsTxt, buildReviewSchemaParts, buildRobotsTxt, buildSeoHeadRouteMap, buildSitemapXml, buildVitePressSeoHead, checkCharsetBudget, checkRemoteAssets, checkSameOriginAssets, classifyUrl, collectEmittedUrlsFromFiles, collectUrlsFromHtml, collectUrlsFromLlmsTxt, collectUrlsFromSitemap, createSeoTransformPageData, decodeHtmlEntities, dedupeUrls, defaultRelativePathToRoute, deriveSameAs, escapeJsonLd, extractBakedHead, filterRealFaq, filterRealReviews, findBusinessLicense, findCharsetByteOffset, findDuplicateNormalizedPaths, findGlobalSchemasOfType, findHeadHonestyExecutionFaults, findHeadHonestyViolations, findLocalBusinessSchema, findPostalAddressGaps, findReviewItemsForPage, formatCharsetHeadroomWarning, formatDuplicateNormalizedPaths, formatEmittedUrlAudit, formatEmittedUrlReport, formatHeadHonestyExecutionReport, formatHeadHonestyReport, formatPostalAddressGapReport, generateJsonLd, generateOpenGraphMeta, generateTwitterMeta, graphAbsorbs, graphIds, headInputIdentities, hoistCharsetMeta, installSeoHead, isBodyPrerenderEnabled, isHandAuthoredRobotsAcceptable, isLocalBusinessType, isManagedLinkRel, isManagedMetaTag, isRouteEmitted, isRouteIndexable, loadPagesManifest, normalizeHeadText, normalizeSeoHeadPath, parsePagesManifest, prerenderBodies, renderHeadTags, resolveHonestyMode, resolvePageSeo, routeExclusionReason, routeToOutputFile, slugToTitle, snapshotBakedManagedHeadTags, spliceBodyHtml, spliceHeadHtml, stripManagedHeadTags, sweepBakedManagedHeadTags };
2222
- //# sourceMappingURL=chunk-W5Q6SOAP.js.map
2223
- //# sourceMappingURL=chunk-W5Q6SOAP.js.map
2258
+ //# sourceMappingURL=chunk-JWXI5HAZ.js.map
2259
+ //# sourceMappingURL=chunk-JWXI5HAZ.js.map