@ecency/render-helper 2.4.23 → 2.4.25

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.
@@ -104,7 +104,7 @@ var TWITCH_REGEX = /https?:\/\/(?:www.)?twitch.tv\/(?:(videos)\/)?([a-zA-Z0-9][\
104
104
  var DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr.in\/file\/dapplr-videos\/.*/i;
105
105
  var TRUVVL_REGEX = /^https?:\/\/embed.truvvl.com\/(@[\w.\d-]+)\/(.*)/i;
106
106
  var LBRY_REGEX = /^(https?:)?\/\/lbry.tv\/\$\/embed\/[^?#]+(?:$|[?#])/i;
107
- var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^/?#]+(?:$|[?#])/i;
107
+ var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^?#]+(?:$|[?#])/i;
108
108
  var SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i;
109
109
  var ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/[^/?#]+(?:$|[?#])/i;
110
110
  var SPEAK_REGEX = /(?:https?:\/\/(?:(?:play\.)?3speak\.([a-z]+)\/watch\?v=)|(?:(?:play\.)?3speak\.([a-z]+)\/embed\?v=))([A-Za-z0-9_\-\.\/]+)(&.*)?/i;
@@ -1044,7 +1044,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext) {
1044
1044
  }
1045
1045
 
1046
1046
  // src/methods/iframe.method.ts
1047
- function iframe(el, parentDomain = "ecency.com") {
1047
+ function iframe(el, parentDomain = "ecency.com", forApp = false) {
1048
1048
  if (!el || !el.parentNode) {
1049
1049
  return;
1050
1050
  }
@@ -1088,7 +1088,10 @@ function iframe(el, parentDomain = "ecency.com") {
1088
1088
  normalizedSrc = `${normalizedSrc}&mode=iframe`;
1089
1089
  }
1090
1090
  const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
1091
- const s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1091
+ let s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1092
+ if (forApp && !/[?&]layout=/.test(s)) {
1093
+ s = `${s}&layout=mobile`;
1094
+ }
1092
1095
  el.setAttribute("src", s);
1093
1096
  el.setAttribute("class", "speak-iframe");
1094
1097
  return;
@@ -1237,12 +1240,28 @@ function linkify(content, forApp) {
1237
1240
  }
1238
1241
  );
1239
1242
  content = content.replace(
1240
- /((^|\s)(\/|)@[\w.\d-]+)\/(\S+)/gi,
1241
- (match, u, p1, p2, p3) => {
1243
+ /(^|\s)\/([a-z0-9-]+)\/@([\w.\d-]+)\/(\S+)/gi,
1244
+ (match, preceding, tag, author, p3) => {
1245
+ const authorLower = author.toLowerCase();
1246
+ if (!isValidUsername(authorLower)) return match;
1247
+ const permlink = sanitizePermlink(p3);
1248
+ if (!isValidPermlink(permlink)) return match;
1249
+ if (SECTION_LIST.includes(permlink)) {
1250
+ const attrs = forApp ? `href="https://ecency.com/@${authorLower}/${permlink}"` : `href="/@${authorLower}/${permlink}"`;
1251
+ return `${preceding}<a class="markdown-profile-link" ${attrs}>@${authorLower}/${permlink}</a>`;
1252
+ } else {
1253
+ const attrs = forApp ? `data-author="${authorLower}" data-tag="${tag}" data-permlink="${permlink}"` : `href="/${tag}/@${authorLower}/${permlink}"`;
1254
+ return `${preceding}<a class="markdown-post-link" ${attrs}>@${authorLower}/${permlink}</a>`;
1255
+ }
1256
+ }
1257
+ );
1258
+ content = content.replace(
1259
+ /((^|\s)\/@[\w.\d-]+)\/(\S+)/gi,
1260
+ (match, u, _p1, p3) => {
1242
1261
  const uu = u.trim().toLowerCase().replace("/@", "").replace("@", "");
1243
1262
  const permlink = sanitizePermlink(p3);
1244
1263
  if (!isValidPermlink(permlink)) return match;
1245
- if (SECTION_LIST.some((v) => p3.includes(v))) {
1264
+ if (SECTION_LIST.includes(permlink)) {
1246
1265
  const attrs = forApp ? `href="https://ecency.com/@${uu}/${permlink}"` : `href="/@${uu}/${permlink}"`;
1247
1266
  return ` <a class="markdown-profile-link" ${attrs}>@${uu}/${permlink}</a>`;
1248
1267
  } else {
@@ -1364,7 +1383,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1364
1383
  a(child, forApp, parentDomain, seoContext);
1365
1384
  }
1366
1385
  if (child.nodeName.toLowerCase() === "iframe") {
1367
- iframe(child, parentDomain);
1386
+ iframe(child, parentDomain, forApp);
1368
1387
  }
1369
1388
  if (child.nodeName === "#text") {
1370
1389
  text(child, forApp);