@ecency/render-helper 2.4.8 → 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
  }
@@ -893,7 +904,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
893
904
  const imgEls2 = el.getElementsByTagName("img");
894
905
  if (imgEls2.length === 1 || el.textContent.trim() === href) {
895
906
  if ((match[1] || match[2]) && match[3]) {
896
- const videoHref = `https://3speak.tv/embed?v=${match[3]}`;
907
+ const videoHref = `https://play.3speak.tv/watch?v=${match[3]}&mode=iframe`;
897
908
  el.setAttribute("class", "markdown-video-link markdown-video-link-speak");
898
909
  el.removeAttribute("href");
899
910
  el.setAttribute("data-embed-src", videoHref);
@@ -1026,7 +1037,11 @@ function iframe(el, parentDomain = "ecency.com") {
1026
1037
  return;
1027
1038
  }
1028
1039
  if (src.match(SPEAK_EMBED_REGEX)) {
1029
- let normalizedSrc = src.replace(/3speak\.[a-z]+/i, "3speak.tv");
1040
+ let normalizedSrc = src.replace(/3speak\.[a-z]+/i, "play.3speak.tv");
1041
+ const hasMode = /[?&]mode=/.test(normalizedSrc);
1042
+ if (!hasMode) {
1043
+ normalizedSrc = `${normalizedSrc}&mode=iframe`;
1044
+ }
1030
1045
  const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
1031
1046
  const s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1032
1047
  el.setAttribute("src", s);