@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.
@@ -77,6 +77,7 @@ var DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr\.in\/file\/dapplr-videos\/.*/i
77
77
  var TRUVVL_REGEX = /^https?:\/\/embed\.truvvl\.com\/(@[\w.\d-]+)\/(.*)/i;
78
78
  var LBRY_REGEX = /^(https?:)?\/\/lbry\.tv\/\$\/embed\/[^?#]+(?:$|[?#])/i;
79
79
  var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^?#]+(?:$|[?#])/i;
80
+ var ODYSEE_WATCH_REGEX = /^(?:https?:)?\/\/odysee\.com\/(@[^/?#\s:"'<>\\]+:[^/?#\s:"'<>\\]+\/[^/?#\s:"'<>\\]+:[^/?#\s:"'<>\\]+|[^@/?#\s:"'<>\\][^/?#\s:"'<>\\]*:[^/?#\s:"'<>\\]+)(?:$|[?#])/i;
80
81
  var SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i;
81
82
  var SKATEHYPE_EMBED_REGEX = /^(https?:)?\/\/(www\.)?skatehype\.com\/ifplay\.php\?v=\d+(?:$|[&#])/i;
82
83
  var ARCH_REGEX = /^(https?:)?\/\/archive\.org\/embed\/[^/?#]+(?:$|[?#])/i;
@@ -250,7 +251,13 @@ var EMBED_HOST_PATH_PATTERNS = {
250
251
  "www.rumble.com": /^\/embed\//,
251
252
  "rumble.com": /^\/embed\//,
252
253
  "www.brighteon.com": /^\/embed\//,
253
- "brighteon.com": /^\/embed\//
254
+ "brighteon.com": /^\/embed\//,
255
+ // Odysee's embed route is /$/embed/<claim path>. Both the literal `$` and its
256
+ // percent-encoded spelling occur in the wild: the renderer emits the literal
257
+ // form, while Odysee's own share dialog hands out fully-encoded URLs, and
258
+ // `URL.pathname` does not decode either. ODYSEE_REGEX accepts both for the
259
+ // same reason.
260
+ "odysee.com": /^\/(?:\$|%24)\/embed\//
254
261
  };
255
262
  function isAllowedEmbedSrc(value) {
256
263
  if (!value) return false;
@@ -854,6 +861,33 @@ function getExternalLinkRel(seoContext) {
854
861
  }
855
862
  return "nofollow ugc noopener";
856
863
  }
864
+ function renderPlainVideoLink(el, provider, embedSrc, renderOptions) {
865
+ const baseClass = `markdown-video-link markdown-video-link-${provider}`;
866
+ el.setAttribute("class", baseClass);
867
+ el.removeAttribute("href");
868
+ el.textContent = "";
869
+ el.setAttribute("data-embed-src", embedSrc);
870
+ if (renderOptions?.embedVideosDirectly) {
871
+ const wrapper = el.ownerDocument.createElement("span");
872
+ wrapper.setAttribute("class", "er-embed-frame");
873
+ wrapper.setAttribute("style", "display:block");
874
+ const frame = el.ownerDocument.createElement("iframe");
875
+ frame.setAttribute("src", embedSrc);
876
+ frame.setAttribute("title", "Video player");
877
+ frame.setAttribute(
878
+ "allow",
879
+ "accelerometer; encrypted-media; gyroscope; picture-in-picture; web-share"
880
+ );
881
+ frame.setAttribute("allowfullscreen", "");
882
+ wrapper.appendChild(frame);
883
+ el.appendChild(wrapper);
884
+ el.setAttribute("class", `${baseClass} er-embed`);
885
+ return;
886
+ }
887
+ const play = el.ownerDocument.createElement("span");
888
+ play.setAttribute("class", "markdown-video-play");
889
+ el.appendChild(play);
890
+ }
857
891
  var normalizeValue = (value) => value ? value.trim() : "";
858
892
  var matchesHref = (href, value) => {
859
893
  const normalizedHref = normalizeValue(href);
@@ -1192,41 +1226,22 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
1192
1226
  }
1193
1227
  const BCmatch = href.match(BITCHUTE_REGEX);
1194
1228
  if (BCmatch && BCmatch[1] && el.textContent.trim() === href) {
1195
- const vid = BCmatch[1];
1196
- el.setAttribute("class", "markdown-video-link");
1197
- el.removeAttribute("href");
1198
- const embedSrc = `https://www.bitchute.com/embed/${vid}/`;
1199
- el.textContent = "";
1200
- el.setAttribute("data-embed-src", embedSrc);
1201
- const play = el.ownerDocument.createElement("span");
1202
- play.setAttribute("class", "markdown-video-play");
1203
- el.appendChild(play);
1229
+ renderPlainVideoLink(el, "bitchute", `https://www.bitchute.com/embed/${BCmatch[1]}/`, renderOptions);
1204
1230
  return;
1205
1231
  }
1206
1232
  const RBmatch = href.match(RUMBLE_REGEX);
1207
1233
  if (RBmatch && RBmatch[1] && el.textContent.trim() === href) {
1208
- const vid = RBmatch[1];
1209
- const embedSrc = `https://www.rumble.com/embed/${vid}/?pub=4`;
1210
- el.setAttribute("class", "markdown-video-link");
1211
- el.removeAttribute("href");
1212
- el.textContent = "";
1213
- el.setAttribute("data-embed-src", embedSrc);
1214
- const play = el.ownerDocument.createElement("span");
1215
- play.setAttribute("class", "markdown-video-play");
1216
- el.appendChild(play);
1234
+ renderPlainVideoLink(el, "rumble", `https://www.rumble.com/embed/${RBmatch[1]}/?pub=4`, renderOptions);
1217
1235
  return;
1218
1236
  }
1219
1237
  const BNmatch = href.match(BRIGHTEON_REGEX);
1220
1238
  if (BNmatch && BNmatch[2] && el.textContent.trim() === href) {
1221
- const vid = BNmatch[2];
1222
- const embedSrc = `https://www.brighteon.com/embed/${vid}`;
1223
- el.setAttribute("class", "markdown-video-link");
1224
- el.removeAttribute("href");
1225
- el.textContent = "";
1226
- el.setAttribute("data-embed-src", embedSrc);
1227
- const play = el.ownerDocument.createElement("span");
1228
- play.setAttribute("class", "markdown-video-play");
1229
- el.appendChild(play);
1239
+ renderPlainVideoLink(el, "brighteon", `https://www.brighteon.com/embed/${BNmatch[2]}`, renderOptions);
1240
+ return;
1241
+ }
1242
+ const ODmatch = href.match(ODYSEE_WATCH_REGEX);
1243
+ if (ODmatch && ODmatch[1] && el.textContent.trim() === href) {
1244
+ renderPlainVideoLink(el, "odysee", `https://odysee.com/$/embed/${ODmatch[1]}`, renderOptions);
1230
1245
  return;
1231
1246
  }
1232
1247
  let match = href.match(YOUTUBE_REGEX);