aeorank 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -209,18 +209,21 @@ async function prefetchSiteData(domain) {
209
209
  if (homepage) homepage.category = "homepage";
210
210
  return { domain, protocol, homepage, llmsTxt, robotsTxt, faqPage, sitemapXml, rssFeed, aiTxt, redirectedTo: null, parkedReason: null, blogSample };
211
211
  }
212
+ function stripScripts(html) {
213
+ return html.replace(/<script(?![^>]*type\s*=\s*["']application\/ld\+json["'])[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "");
214
+ }
212
215
  function getCombinedHtml(data) {
213
- const parts = [data.homepage?.text || ""];
216
+ const parts = [stripScripts(data.homepage?.text || "")];
214
217
  if (data.blogSample) {
215
218
  for (const page of data.blogSample) {
216
- parts.push(page.text);
219
+ parts.push(stripScripts(page.text));
217
220
  }
218
221
  }
219
222
  return parts.join("\n");
220
223
  }
221
224
  function getBlogHtml(data) {
222
225
  if (!data.blogSample || data.blogSample.length === 0) return "";
223
- return data.blogSample.map((p) => p.text).join("\n");
226
+ return data.blogSample.map((p) => stripScripts(p.text)).join("\n");
224
227
  }
225
228
  function checkLlmsTxt(data) {
226
229
  const findings = [];
@@ -1418,14 +1421,17 @@ function checkQueryAnswerAlignment(data) {
1418
1421
  }
1419
1422
  let answered = 0;
1420
1423
  for (const qHeading of questionHeadings) {
1421
- const escapedHeading = qHeading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1422
- const pattern = new RegExp(escapedHeading + "[\\s\\S]{0,200}?<\\/h[23]>([\\s\\S]{0,1500}?)(?=<h[1-6]|$)", "i");
1423
- const match = pattern.exec(combinedHtml);
1424
- if (match) {
1425
- const afterContent = match[1].replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
1426
- if (afterContent.length >= 20) {
1427
- answered++;
1424
+ try {
1425
+ const escapedHeading = qHeading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1426
+ const pattern = new RegExp(escapedHeading + "[\\s\\S]{0,200}?<\\/h[23]>([\\s\\S]{0,1500}?)(?=<h[1-6]|$)", "i");
1427
+ const match = pattern.exec(combinedHtml);
1428
+ if (match) {
1429
+ const afterContent = match[1].replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
1430
+ if (afterContent.length >= 20) {
1431
+ answered++;
1432
+ }
1428
1433
  }
1434
+ } catch {
1429
1435
  }
1430
1436
  }
1431
1437
  const rate = Math.round(answered / questionHeadings.length * 100);
@@ -1904,27 +1910,32 @@ function checkTopicCoherence(data) {
1904
1910
  const bigramFocusRatio = blogPages.length > 0 ? dominantBigramCount / blogPages.length : 0;
1905
1911
  let score = 0;
1906
1912
  const bestFocusRatio = Math.max(focusRatio, bigramFocusRatio);
1913
+ const dominantPageCount = Math.max(dominantTermCount, dominantBigramCount);
1914
+ const hasStrongAbsolutePresence = dominantPageCount >= 10;
1907
1915
  if (bestFocusRatio >= 0.8) {
1908
1916
  score += 7;
1909
1917
  } else if (bestFocusRatio >= 0.6) {
1910
1918
  score += 6;
1911
- } else if (bestFocusRatio >= 0.45) {
1919
+ } else if (bestFocusRatio >= 0.45 || hasStrongAbsolutePresence && bestFocusRatio >= 0.3) {
1912
1920
  score += 5;
1913
- } else if (bestFocusRatio >= 0.3) {
1914
- score += 3;
1921
+ } else if (bestFocusRatio >= 0.3 || hasStrongAbsolutePresence && bestFocusRatio >= 0.2) {
1922
+ score += 4;
1915
1923
  } else if (bestFocusRatio >= 0.15) {
1916
1924
  score += 2;
1917
1925
  } else {
1918
1926
  score += 1;
1919
1927
  }
1920
- const clusterPenaltyReduced = focusRatio >= 0.7;
1921
- if (topicClusterCount <= 3) {
1928
+ const clusterPenaltyReduced = focusRatio >= 0.7 || hasStrongAbsolutePresence;
1929
+ const scaledLow = Math.max(3, Math.floor(blogPages.length / 10));
1930
+ const scaledMid = Math.max(6, Math.floor(blogPages.length / 5));
1931
+ const scaledHigh = Math.max(10, Math.floor(blogPages.length / 3));
1932
+ if (topicClusterCount <= scaledLow) {
1922
1933
  score += 3;
1923
1934
  findings.push({ severity: "info", detail: `${topicClusterCount} topic cluster(s) - tightly focused content` });
1924
- } else if (topicClusterCount <= 6) {
1935
+ } else if (topicClusterCount <= scaledMid) {
1925
1936
  score += clusterPenaltyReduced ? 2 : 1;
1926
1937
  findings.push({ severity: "info", detail: `${topicClusterCount} topic clusters${clusterPenaltyReduced ? " within a focused niche" : " - moderately focused"}` });
1927
- } else if (topicClusterCount <= 10) {
1938
+ } else if (topicClusterCount <= scaledHigh) {
1928
1939
  score += clusterPenaltyReduced ? 1 : 0;
1929
1940
  if (!clusterPenaltyReduced) {
1930
1941
  findings.push({ severity: "low", detail: `${topicClusterCount} topic clusters - scattered content`, fix: "Reduce the number of distinct topics. Focus blog content on 2-3 core expertise areas." });