@ecency/render-helper 2.5.22 → 2.5.23

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.
@@ -105,6 +105,7 @@ 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
107
  var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^?#]+(?:$|[?#])/i;
108
+ var ODYSEE_WATCH_REGEX = /^(?:https?:)?\/\/odysee\.com\/(@[^/?#\s:"'<>\\]+:[^/?#\s:"'<>\\]+\/[^/?#\s:"'<>\\]+:[^/?#\s:"'<>\\]+|[^@/?#\s:"'<>\\][^/?#\s:"'<>\\]*:[^/?#\s:"'<>\\]+)(?:$|[?#])/i;
108
109
  var SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i;
109
110
  var SKATEHYPE_EMBED_REGEX = /^(https?:)?\/\/(www\.)?skatehype\.com\/ifplay\.php\?v=\d+(?:$|[&#])/i;
110
111
  var ARCH_REGEX = /^(https?:)?\/\/archive\.org\/embed\/[^/?#]+(?:$|[?#])/i;
@@ -278,7 +279,13 @@ var EMBED_HOST_PATH_PATTERNS = {
278
279
  "www.rumble.com": /^\/embed\//,
279
280
  "rumble.com": /^\/embed\//,
280
281
  "www.brighteon.com": /^\/embed\//,
281
- "brighteon.com": /^\/embed\//
282
+ "brighteon.com": /^\/embed\//,
283
+ // Odysee's embed route is /$/embed/<claim path>. Both the literal `$` and its
284
+ // percent-encoded spelling occur in the wild: the renderer emits the literal
285
+ // form, while Odysee's own share dialog hands out fully-encoded URLs, and
286
+ // `URL.pathname` does not decode either. ODYSEE_REGEX accepts both for the
287
+ // same reason.
288
+ "odysee.com": /^\/(?:\$|%24)\/embed\//
282
289
  };
283
290
  function isAllowedEmbedSrc(value) {
284
291
  if (!value) return false;
@@ -882,6 +889,33 @@ function getExternalLinkRel(seoContext) {
882
889
  }
883
890
  return "nofollow ugc noopener";
884
891
  }
892
+ function renderPlainVideoLink(el, provider, embedSrc, renderOptions) {
893
+ const baseClass = `markdown-video-link markdown-video-link-${provider}`;
894
+ el.setAttribute("class", baseClass);
895
+ el.removeAttribute("href");
896
+ el.textContent = "";
897
+ el.setAttribute("data-embed-src", embedSrc);
898
+ if (renderOptions?.embedVideosDirectly) {
899
+ const wrapper = el.ownerDocument.createElement("span");
900
+ wrapper.setAttribute("class", "er-embed-frame");
901
+ wrapper.setAttribute("style", "display:block");
902
+ const frame = el.ownerDocument.createElement("iframe");
903
+ frame.setAttribute("src", embedSrc);
904
+ frame.setAttribute("title", "Video player");
905
+ frame.setAttribute(
906
+ "allow",
907
+ "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share"
908
+ );
909
+ frame.setAttribute("allowfullscreen", "");
910
+ wrapper.appendChild(frame);
911
+ el.appendChild(wrapper);
912
+ el.setAttribute("class", `${baseClass} er-embed`);
913
+ return;
914
+ }
915
+ const play = el.ownerDocument.createElement("span");
916
+ play.setAttribute("class", "markdown-video-play");
917
+ el.appendChild(play);
918
+ }
885
919
  var normalizeValue = (value) => value ? value.trim() : "";
886
920
  var matchesHref = (href, value) => {
887
921
  const normalizedHref = normalizeValue(href);
@@ -1220,41 +1254,22 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1220
1254
  }
1221
1255
  const BCmatch = href.match(BITCHUTE_REGEX);
1222
1256
  if (BCmatch && BCmatch[1] && el.textContent.trim() === href) {
1223
- const vid = BCmatch[1];
1224
- el.setAttribute("class", "markdown-video-link");
1225
- el.removeAttribute("href");
1226
- const embedSrc = `https://www.bitchute.com/embed/${vid}/`;
1227
- el.textContent = "";
1228
- el.setAttribute("data-embed-src", embedSrc);
1229
- const play = el.ownerDocument.createElement("span");
1230
- play.setAttribute("class", "markdown-video-play");
1231
- el.appendChild(play);
1257
+ renderPlainVideoLink(el, "bitchute", `https://www.bitchute.com/embed/${BCmatch[1]}/`, renderOptions);
1232
1258
  return;
1233
1259
  }
1234
1260
  const RBmatch = href.match(RUMBLE_REGEX);
1235
1261
  if (RBmatch && RBmatch[1] && el.textContent.trim() === href) {
1236
- const vid = RBmatch[1];
1237
- const embedSrc = `https://www.rumble.com/embed/${vid}/?pub=4`;
1238
- el.setAttribute("class", "markdown-video-link");
1239
- el.removeAttribute("href");
1240
- el.textContent = "";
1241
- el.setAttribute("data-embed-src", embedSrc);
1242
- const play = el.ownerDocument.createElement("span");
1243
- play.setAttribute("class", "markdown-video-play");
1244
- el.appendChild(play);
1262
+ renderPlainVideoLink(el, "rumble", `https://www.rumble.com/embed/${RBmatch[1]}/?pub=4`, renderOptions);
1245
1263
  return;
1246
1264
  }
1247
1265
  const BNmatch = href.match(BRIGHTEON_REGEX);
1248
1266
  if (BNmatch && BNmatch[2] && el.textContent.trim() === href) {
1249
- const vid = BNmatch[2];
1250
- const embedSrc = `https://www.brighteon.com/embed/${vid}`;
1251
- el.setAttribute("class", "markdown-video-link");
1252
- el.removeAttribute("href");
1253
- el.textContent = "";
1254
- el.setAttribute("data-embed-src", embedSrc);
1255
- const play = el.ownerDocument.createElement("span");
1256
- play.setAttribute("class", "markdown-video-play");
1257
- el.appendChild(play);
1267
+ renderPlainVideoLink(el, "brighteon", `https://www.brighteon.com/embed/${BNmatch[2]}`, renderOptions);
1268
+ return;
1269
+ }
1270
+ const ODmatch = href.match(ODYSEE_WATCH_REGEX);
1271
+ if (ODmatch && ODmatch[1] && el.textContent.trim() === href) {
1272
+ renderPlainVideoLink(el, "odysee", `https://odysee.com/$/embed/${ODmatch[1]}`, renderOptions);
1258
1273
  return;
1259
1274
  }
1260
1275
  let match = href.match(YOUTUBE_REGEX);