@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.
@@ -75,7 +75,7 @@ var TWITCH_REGEX = /https?:\/\/(?:www.)?twitch.tv\/(?:(videos)\/)?([a-zA-Z0-9][\
75
75
  var DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr.in\/file\/dapplr-videos\/.*/i;
76
76
  var TRUVVL_REGEX = /^https?:\/\/embed.truvvl.com\/(@[\w.\d-]+)\/(.*)/i;
77
77
  var LBRY_REGEX = /^(https?:)?\/\/lbry.tv\/\$\/embed\/[^?#]+(?:$|[?#])/i;
78
- var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^/?#]+(?:$|[?#])/i;
78
+ var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^?#]+(?:$|[?#])/i;
79
79
  var SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i;
80
80
  var ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/[^/?#]+(?:$|[?#])/i;
81
81
  var SPEAK_REGEX = /(?:https?:\/\/(?:(?:play\.)?3speak\.([a-z]+)\/watch\?v=)|(?:(?:play\.)?3speak\.([a-z]+)\/embed\?v=))([A-Za-z0-9_\-\.\/]+)(&.*)?/i;
@@ -1012,7 +1012,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext) {
1012
1012
  }
1013
1013
 
1014
1014
  // src/methods/iframe.method.ts
1015
- function iframe(el, parentDomain = "ecency.com") {
1015
+ function iframe(el, parentDomain = "ecency.com", forApp = false) {
1016
1016
  if (!el || !el.parentNode) {
1017
1017
  return;
1018
1018
  }
@@ -1056,7 +1056,10 @@ function iframe(el, parentDomain = "ecency.com") {
1056
1056
  normalizedSrc = `${normalizedSrc}&mode=iframe`;
1057
1057
  }
1058
1058
  const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
1059
- const s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1059
+ let s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1060
+ if (forApp && !/[?&]layout=/.test(s)) {
1061
+ s = `${s}&layout=mobile`;
1062
+ }
1060
1063
  el.setAttribute("src", s);
1061
1064
  el.setAttribute("class", "speak-iframe");
1062
1065
  return;
@@ -1205,12 +1208,28 @@ function linkify(content, forApp) {
1205
1208
  }
1206
1209
  );
1207
1210
  content = content.replace(
1208
- /((^|\s)(\/|)@[\w.\d-]+)\/(\S+)/gi,
1209
- (match, u, p1, p2, p3) => {
1211
+ /(^|\s)\/([a-z0-9-]+)\/@([\w.\d-]+)\/(\S+)/gi,
1212
+ (match, preceding, tag, author, p3) => {
1213
+ const authorLower = author.toLowerCase();
1214
+ if (!isValidUsername(authorLower)) return match;
1215
+ const permlink = sanitizePermlink(p3);
1216
+ if (!isValidPermlink(permlink)) return match;
1217
+ if (SECTION_LIST.includes(permlink)) {
1218
+ const attrs = forApp ? `href="https://ecency.com/@${authorLower}/${permlink}"` : `href="/@${authorLower}/${permlink}"`;
1219
+ return `${preceding}<a class="markdown-profile-link" ${attrs}>@${authorLower}/${permlink}</a>`;
1220
+ } else {
1221
+ const attrs = forApp ? `data-author="${authorLower}" data-tag="${tag}" data-permlink="${permlink}"` : `href="/${tag}/@${authorLower}/${permlink}"`;
1222
+ return `${preceding}<a class="markdown-post-link" ${attrs}>@${authorLower}/${permlink}</a>`;
1223
+ }
1224
+ }
1225
+ );
1226
+ content = content.replace(
1227
+ /((^|\s)\/@[\w.\d-]+)\/(\S+)/gi,
1228
+ (match, u, _p1, p3) => {
1210
1229
  const uu = u.trim().toLowerCase().replace("/@", "").replace("@", "");
1211
1230
  const permlink = sanitizePermlink(p3);
1212
1231
  if (!isValidPermlink(permlink)) return match;
1213
- if (SECTION_LIST.some((v) => p3.includes(v))) {
1232
+ if (SECTION_LIST.includes(permlink)) {
1214
1233
  const attrs = forApp ? `href="https://ecency.com/@${uu}/${permlink}"` : `href="/@${uu}/${permlink}"`;
1215
1234
  return ` <a class="markdown-profile-link" ${attrs}>@${uu}/${permlink}</a>`;
1216
1235
  } else {
@@ -1332,7 +1351,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1332
1351
  a(child, forApp, parentDomain, seoContext);
1333
1352
  }
1334
1353
  if (child.nodeName.toLowerCase() === "iframe") {
1335
- iframe(child, parentDomain);
1354
+ iframe(child, parentDomain, forApp);
1336
1355
  }
1337
1356
  if (child.nodeName === "#text") {
1338
1357
  text(child, forApp);