@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/node/index.mjs
CHANGED
|
@@ -379,13 +379,23 @@ var matchesHref = (href, value) => {
|
|
|
379
379
|
}
|
|
380
380
|
return normalizeValue(value) === normalizedHref;
|
|
381
381
|
};
|
|
382
|
-
var
|
|
382
|
+
var normalizeDisplayText = (text2) => {
|
|
383
|
+
return text2.trim().replace(/^https?:\/\/(www\.)?(ecency\.com|peakd\.com|hive\.blog)/i, "").replace(/^\/+/, "").split("?")[0].replace(/#@.*$/i, "").replace(/\/+$/, "").toLowerCase();
|
|
384
|
+
};
|
|
385
|
+
var getInlineMeta = (el, href, author, permlink, communityTag) => {
|
|
383
386
|
const textMatches = matchesHref(href, el.textContent);
|
|
384
387
|
const titleMatches = matchesHref(href, el.getAttribute("title"));
|
|
388
|
+
const normalizedDisplay = normalizeDisplayText(el.textContent || "");
|
|
389
|
+
const normalizedTarget = `@${author}/${permlink}`.toLowerCase();
|
|
390
|
+
const expectedDisplays = /* @__PURE__ */ new Set([normalizedTarget]);
|
|
391
|
+
if (communityTag) {
|
|
392
|
+
expectedDisplays.add(`${communityTag.toLowerCase()}/${normalizedTarget}`);
|
|
393
|
+
}
|
|
394
|
+
const sophisticatedMatch = normalizedDisplay === normalizedTarget || communityTag && normalizedDisplay === `${communityTag.toLowerCase()}/${normalizedTarget}`;
|
|
385
395
|
return {
|
|
386
396
|
textMatches,
|
|
387
397
|
titleMatches,
|
|
388
|
-
isInline: textMatches || titleMatches
|
|
398
|
+
isInline: textMatches || titleMatches || sophisticatedMatch
|
|
389
399
|
};
|
|
390
400
|
};
|
|
391
401
|
var addLineBreakBeforePostLink = (el, forApp, isInline) => {
|
|
@@ -440,7 +450,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
440
450
|
const author = postMatch[3].replace("@", "");
|
|
441
451
|
const permlink = sanitizePermlink(postMatch[4]);
|
|
442
452
|
if (!isValidPermlink(permlink)) return;
|
|
443
|
-
const inlineMeta = getInlineMeta(el, href);
|
|
453
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink);
|
|
444
454
|
if (inlineMeta.textMatches) {
|
|
445
455
|
el.textContent = `@${author}/${permlink}`;
|
|
446
456
|
}
|
|
@@ -518,7 +528,8 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
518
528
|
const author = tpostMatch[2].replace("@", "");
|
|
519
529
|
const permlink = sanitizePermlink(tpostMatch[3]);
|
|
520
530
|
if (!isValidPermlink(permlink)) return;
|
|
521
|
-
const
|
|
531
|
+
const communityTag = tag.toLowerCase().startsWith("hive-") ? tag : void 0;
|
|
532
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink, communityTag);
|
|
522
533
|
if (inlineMeta.textMatches) {
|
|
523
534
|
el.textContent = `@${author}/${permlink}`;
|
|
524
535
|
}
|
|
@@ -583,7 +594,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
583
594
|
const author = cpostMatch[1].replace("@", "");
|
|
584
595
|
const permlink = sanitizePermlink(cpostMatch[2]);
|
|
585
596
|
if (!isValidPermlink(permlink)) return;
|
|
586
|
-
const inlineMeta = getInlineMeta(el, href);
|
|
597
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink);
|
|
587
598
|
if (inlineMeta.textMatches) {
|
|
588
599
|
el.textContent = `@${author}/${permlink}`;
|
|
589
600
|
}
|
|
@@ -669,7 +680,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
669
680
|
const author = cccMatch[2].replace("@", "");
|
|
670
681
|
const permlink = sanitizePermlink(cccMatch[3]);
|
|
671
682
|
if (!isValidPermlink(permlink)) return;
|
|
672
|
-
const inlineMeta = getInlineMeta(el, href);
|
|
683
|
+
const inlineMeta = getInlineMeta(el, href, author, permlink);
|
|
673
684
|
if (inlineMeta.textMatches) {
|
|
674
685
|
el.textContent = `@${author}/${permlink}`;
|
|
675
686
|
}
|
|
@@ -864,7 +875,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
864
875
|
const imgEls2 = el.getElementsByTagName("img");
|
|
865
876
|
if (imgEls2.length === 1 || el.textContent.trim() === href) {
|
|
866
877
|
if ((match[1] || match[2]) && match[3]) {
|
|
867
|
-
const videoHref = `https://3speak.tv/
|
|
878
|
+
const videoHref = `https://play.3speak.tv/watch?v=${match[3]}&mode=iframe`;
|
|
868
879
|
el.setAttribute("class", "markdown-video-link markdown-video-link-speak");
|
|
869
880
|
el.removeAttribute("href");
|
|
870
881
|
el.setAttribute("data-embed-src", videoHref);
|
|
@@ -997,7 +1008,11 @@ function iframe(el, parentDomain = "ecency.com") {
|
|
|
997
1008
|
return;
|
|
998
1009
|
}
|
|
999
1010
|
if (src.match(SPEAK_EMBED_REGEX)) {
|
|
1000
|
-
let normalizedSrc = src.replace(/3speak\.[a-z]+/i, "3speak.tv");
|
|
1011
|
+
let normalizedSrc = src.replace(/3speak\.[a-z]+/i, "play.3speak.tv");
|
|
1012
|
+
const hasMode = /[?&]mode=/.test(normalizedSrc);
|
|
1013
|
+
if (!hasMode) {
|
|
1014
|
+
normalizedSrc = `${normalizedSrc}&mode=iframe`;
|
|
1015
|
+
}
|
|
1001
1016
|
const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
|
|
1002
1017
|
const s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
|
|
1003
1018
|
el.setAttribute("src", s);
|