@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.
- package/dist/browser/index.js +23 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +23 -8
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +23 -8
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -376,13 +376,23 @@ var matchesHref = (href, value) => {
|
|
|
376
376
|
}
|
|
377
377
|
return normalizeValue(value) === normalizedHref;
|
|
378
378
|
};
|
|
379
|
-
var
|
|
379
|
+
var normalizeDisplayText = (text2) => {
|
|
380
|
+
return text2.trim().replace(/^https?:\/\/(www\.)?(ecency\.com|peakd\.com|hive\.blog)/i, "").replace(/^\/+/, "").split("?")[0].replace(/#@.*$/i, "").replace(/\/+$/, "").toLowerCase();
|
|
381
|
+
};
|
|
382
|
+
var getInlineMeta = (el, href, author, permlink, communityTag) => {
|
|
380
383
|
const textMatches = matchesHref(href, el.textContent);
|
|
381
384
|
const titleMatches = matchesHref(href, el.getAttribute("title"));
|
|
385
|
+
const normalizedDisplay = normalizeDisplayText(el.textContent || "");
|
|
386
|
+
const normalizedTarget = `@${author}/${permlink}`.toLowerCase();
|
|
387
|
+
const expectedDisplays = /* @__PURE__ */ new Set([normalizedTarget]);
|
|
388
|
+
if (communityTag) {
|
|
389
|
+
expectedDisplays.add(`${communityTag.toLowerCase()}/${normalizedTarget}`);
|
|
390
|
+
}
|
|
391
|
+
const sophisticatedMatch = normalizedDisplay === normalizedTarget || communityTag && normalizedDisplay === `${communityTag.toLowerCase()}/${normalizedTarget}`;
|
|
382
392
|
return {
|
|
383
393
|
textMatches,
|
|
384
394
|
titleMatches,
|
|
385
|
-
isInline: textMatches || titleMatches
|
|
395
|
+
isInline: textMatches || titleMatches || sophisticatedMatch
|
|
386
396
|
};
|
|
387
397
|
};
|
|
388
398
|
var addLineBreakBeforePostLink = (el, forApp, isInline) => {
|
|
@@ -437,7 +447,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
437
447
|
const author = postMatch[3].replace("@", "");
|
|
438
448
|
const permlink = sanitizePermlink(postMatch[4]);
|
|
439
449
|
if (!isValidPermlink(permlink)) return;
|
|
440
|
-
const inlineMeta = getInlineMeta(el, href);
|
|
450
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink);
|
|
441
451
|
if (inlineMeta.textMatches) {
|
|
442
452
|
el.textContent = `@${author}/${permlink}`;
|
|
443
453
|
}
|
|
@@ -515,7 +525,8 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
515
525
|
const author = tpostMatch[2].replace("@", "");
|
|
516
526
|
const permlink = sanitizePermlink(tpostMatch[3]);
|
|
517
527
|
if (!isValidPermlink(permlink)) return;
|
|
518
|
-
const
|
|
528
|
+
const communityTag = tag.toLowerCase().startsWith("hive-") ? tag : void 0;
|
|
529
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink, communityTag);
|
|
519
530
|
if (inlineMeta.textMatches) {
|
|
520
531
|
el.textContent = `@${author}/${permlink}`;
|
|
521
532
|
}
|
|
@@ -580,7 +591,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
580
591
|
const author = cpostMatch[1].replace("@", "");
|
|
581
592
|
const permlink = sanitizePermlink(cpostMatch[2]);
|
|
582
593
|
if (!isValidPermlink(permlink)) return;
|
|
583
|
-
const inlineMeta = getInlineMeta(el, href);
|
|
594
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink);
|
|
584
595
|
if (inlineMeta.textMatches) {
|
|
585
596
|
el.textContent = `@${author}/${permlink}`;
|
|
586
597
|
}
|
|
@@ -666,7 +677,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
666
677
|
const author = cccMatch[2].replace("@", "");
|
|
667
678
|
const permlink = sanitizePermlink(cccMatch[3]);
|
|
668
679
|
if (!isValidPermlink(permlink)) return;
|
|
669
|
-
const inlineMeta = getInlineMeta(el, href);
|
|
680
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink);
|
|
670
681
|
if (inlineMeta.textMatches) {
|
|
671
682
|
el.textContent = `@${author}/${permlink}`;
|
|
672
683
|
}
|
|
@@ -861,7 +872,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
861
872
|
const imgEls2 = el.getElementsByTagName("img");
|
|
862
873
|
if (imgEls2.length === 1 || el.textContent.trim() === href) {
|
|
863
874
|
if ((match[1] || match[2]) && match[3]) {
|
|
864
|
-
const videoHref = `https://3speak.tv/
|
|
875
|
+
const videoHref = `https://play.3speak.tv/watch?v=${match[3]}&mode=iframe`;
|
|
865
876
|
el.setAttribute("class", "markdown-video-link markdown-video-link-speak");
|
|
866
877
|
el.removeAttribute("href");
|
|
867
878
|
el.setAttribute("data-embed-src", videoHref);
|
|
@@ -994,7 +1005,11 @@ function iframe(el, parentDomain = "ecency.com") {
|
|
|
994
1005
|
return;
|
|
995
1006
|
}
|
|
996
1007
|
if (src.match(SPEAK_EMBED_REGEX)) {
|
|
997
|
-
let normalizedSrc = src.replace(/3speak\.[a-z]+/i, "3speak.tv");
|
|
1008
|
+
let normalizedSrc = src.replace(/3speak\.[a-z]+/i, "play.3speak.tv");
|
|
1009
|
+
const hasMode = /[?&]mode=/.test(normalizedSrc);
|
|
1010
|
+
if (!hasMode) {
|
|
1011
|
+
normalizedSrc = `${normalizedSrc}&mode=iframe`;
|
|
1012
|
+
}
|
|
998
1013
|
const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
|
|
999
1014
|
const s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
|
|
1000
1015
|
el.setAttribute("src", s);
|