@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;
@@ -1015,7 +1015,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext) {
1015
1015
  }
1016
1016
 
1017
1017
  // src/methods/iframe.method.ts
1018
- function iframe(el, parentDomain = "ecency.com") {
1018
+ function iframe(el, parentDomain = "ecency.com", forApp = false) {
1019
1019
  if (!el || !el.parentNode) {
1020
1020
  return;
1021
1021
  }
@@ -1059,7 +1059,10 @@ function iframe(el, parentDomain = "ecency.com") {
1059
1059
  normalizedSrc = `${normalizedSrc}&mode=iframe`;
1060
1060
  }
1061
1061
  const hasAutoplay = /[?&]autoplay=/.test(normalizedSrc);
1062
- const s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1062
+ let s = hasAutoplay ? normalizedSrc : `${normalizedSrc}&autoplay=true`;
1063
+ if (forApp && !/[?&]layout=/.test(s)) {
1064
+ s = `${s}&layout=mobile`;
1065
+ }
1063
1066
  el.setAttribute("src", s);
1064
1067
  el.setAttribute("class", "speak-iframe");
1065
1068
  return;
@@ -1208,12 +1211,28 @@ function linkify(content, forApp) {
1208
1211
  }
1209
1212
  );
1210
1213
  content = content.replace(
1211
- /((^|\s)(\/|)@[\w.\d-]+)\/(\S+)/gi,
1212
- (match, u, p1, p2, p3) => {
1214
+ /(^|\s)\/([a-z0-9-]+)\/@([\w.\d-]+)\/(\S+)/gi,
1215
+ (match, preceding, tag, author, p3) => {
1216
+ const authorLower = author.toLowerCase();
1217
+ if (!isValidUsername(authorLower)) return match;
1218
+ const permlink = sanitizePermlink(p3);
1219
+ if (!isValidPermlink(permlink)) return match;
1220
+ if (SECTION_LIST.includes(permlink)) {
1221
+ const attrs = forApp ? `href="https://ecency.com/@${authorLower}/${permlink}"` : `href="/@${authorLower}/${permlink}"`;
1222
+ return `${preceding}<a class="markdown-profile-link" ${attrs}>@${authorLower}/${permlink}</a>`;
1223
+ } else {
1224
+ const attrs = forApp ? `data-author="${authorLower}" data-tag="${tag}" data-permlink="${permlink}"` : `href="/${tag}/@${authorLower}/${permlink}"`;
1225
+ return `${preceding}<a class="markdown-post-link" ${attrs}>@${authorLower}/${permlink}</a>`;
1226
+ }
1227
+ }
1228
+ );
1229
+ content = content.replace(
1230
+ /((^|\s)\/@[\w.\d-]+)\/(\S+)/gi,
1231
+ (match, u, _p1, p3) => {
1213
1232
  const uu = u.trim().toLowerCase().replace("/@", "").replace("@", "");
1214
1233
  const permlink = sanitizePermlink(p3);
1215
1234
  if (!isValidPermlink(permlink)) return match;
1216
- if (SECTION_LIST.some((v) => p3.includes(v))) {
1235
+ if (SECTION_LIST.includes(permlink)) {
1217
1236
  const attrs = forApp ? `href="https://ecency.com/@${uu}/${permlink}"` : `href="/@${uu}/${permlink}"`;
1218
1237
  return ` <a class="markdown-profile-link" ${attrs}>@${uu}/${permlink}</a>`;
1219
1238
  } else {
@@ -1335,7 +1354,7 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1335
1354
  a(child, forApp, parentDomain, seoContext);
1336
1355
  }
1337
1356
  if (child.nodeName.toLowerCase() === "iframe") {
1338
- iframe(child, parentDomain);
1357
+ iframe(child, parentDomain, forApp);
1339
1358
  }
1340
1359
  if (child.nodeName === "#text") {
1341
1360
  text(child, forApp);