@ecency/render-helper 2.4.9 → 2.4.10

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.
@@ -408,13 +408,23 @@ var matchesHref = (href, value) => {
408
408
  }
409
409
  return normalizeValue(value) === normalizedHref;
410
410
  };
411
- var getInlineMeta = (el, href) => {
411
+ var normalizeDisplayText = (text2) => {
412
+ return text2.trim().replace(/^https?:\/\/(www\.)?(ecency\.com|peakd\.com|hive\.blog)/i, "").replace(/^\/+/, "").split("?")[0].replace(/#@.*$/i, "").replace(/\/+$/, "").toLowerCase();
413
+ };
414
+ var getInlineMeta = (el, href, author, permlink, communityTag) => {
412
415
  const textMatches = matchesHref(href, el.textContent);
413
416
  const titleMatches = matchesHref(href, el.getAttribute("title"));
417
+ const normalizedDisplay = normalizeDisplayText(el.textContent || "");
418
+ const normalizedTarget = `@${author}/${permlink}`.toLowerCase();
419
+ const expectedDisplays = /* @__PURE__ */ new Set([normalizedTarget]);
420
+ if (communityTag) {
421
+ expectedDisplays.add(`${communityTag.toLowerCase()}/${normalizedTarget}`);
422
+ }
423
+ const sophisticatedMatch = normalizedDisplay === normalizedTarget || communityTag && normalizedDisplay === `${communityTag.toLowerCase()}/${normalizedTarget}`;
414
424
  return {
415
425
  textMatches,
416
426
  titleMatches,
417
- isInline: textMatches || titleMatches
427
+ isInline: textMatches || titleMatches || sophisticatedMatch
418
428
  };
419
429
  };
420
430
  var addLineBreakBeforePostLink = (el, forApp, isInline) => {
@@ -469,7 +479,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
469
479
  const author = postMatch[3].replace("@", "");
470
480
  const permlink = sanitizePermlink(postMatch[4]);
471
481
  if (!isValidPermlink(permlink)) return;
472
- const inlineMeta = getInlineMeta(el, href);
482
+ const inlineMeta = getInlineMeta(el, href, author, permlink);
473
483
  if (inlineMeta.textMatches) {
474
484
  el.textContent = `@${author}/${permlink}`;
475
485
  }
@@ -547,7 +557,8 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
547
557
  const author = tpostMatch[2].replace("@", "");
548
558
  const permlink = sanitizePermlink(tpostMatch[3]);
549
559
  if (!isValidPermlink(permlink)) return;
550
- const inlineMeta = getInlineMeta(el, href);
560
+ const communityTag = tag.toLowerCase().startsWith("hive-") ? tag : void 0;
561
+ const inlineMeta = getInlineMeta(el, href, author, permlink, communityTag);
551
562
  if (inlineMeta.textMatches) {
552
563
  el.textContent = `@${author}/${permlink}`;
553
564
  }
@@ -612,7 +623,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
612
623
  const author = cpostMatch[1].replace("@", "");
613
624
  const permlink = sanitizePermlink(cpostMatch[2]);
614
625
  if (!isValidPermlink(permlink)) return;
615
- const inlineMeta = getInlineMeta(el, href);
626
+ const inlineMeta = getInlineMeta(el, href, author, permlink);
616
627
  if (inlineMeta.textMatches) {
617
628
  el.textContent = `@${author}/${permlink}`;
618
629
  }
@@ -698,7 +709,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
698
709
  const author = cccMatch[2].replace("@", "");
699
710
  const permlink = sanitizePermlink(cccMatch[3]);
700
711
  if (!isValidPermlink(permlink)) return;
701
- const inlineMeta = getInlineMeta(el, href);
712
+ const inlineMeta = getInlineMeta(el, href, author, permlink);
702
713
  if (inlineMeta.textMatches) {
703
714
  el.textContent = `@${author}/${permlink}`;
704
715
  }