@ecency/render-helper 2.4.22 → 2.4.24
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.
- package/dist/browser/index.js +31 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +31 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +31 -5
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -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\/[
|
|
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;
|
|
@@ -1205,12 +1205,28 @@ function linkify(content, forApp) {
|
|
|
1205
1205
|
}
|
|
1206
1206
|
);
|
|
1207
1207
|
content = content.replace(
|
|
1208
|
-
/(
|
|
1209
|
-
(match,
|
|
1208
|
+
/(^|\s)\/([a-z0-9-]+)\/@([\w.\d-]+)\/(\S+)/gi,
|
|
1209
|
+
(match, preceding, tag, author, p3) => {
|
|
1210
|
+
const authorLower = author.toLowerCase();
|
|
1211
|
+
if (!isValidUsername(authorLower)) return match;
|
|
1212
|
+
const permlink = sanitizePermlink(p3);
|
|
1213
|
+
if (!isValidPermlink(permlink)) return match;
|
|
1214
|
+
if (SECTION_LIST.includes(permlink)) {
|
|
1215
|
+
const attrs = forApp ? `href="https://ecency.com/@${authorLower}/${permlink}"` : `href="/@${authorLower}/${permlink}"`;
|
|
1216
|
+
return `${preceding}<a class="markdown-profile-link" ${attrs}>@${authorLower}/${permlink}</a>`;
|
|
1217
|
+
} else {
|
|
1218
|
+
const attrs = forApp ? `data-author="${authorLower}" data-tag="${tag}" data-permlink="${permlink}"` : `href="/${tag}/@${authorLower}/${permlink}"`;
|
|
1219
|
+
return `${preceding}<a class="markdown-post-link" ${attrs}>@${authorLower}/${permlink}</a>`;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
);
|
|
1223
|
+
content = content.replace(
|
|
1224
|
+
/((^|\s)\/@[\w.\d-]+)\/(\S+)/gi,
|
|
1225
|
+
(match, u, _p1, p3) => {
|
|
1210
1226
|
const uu = u.trim().toLowerCase().replace("/@", "").replace("@", "");
|
|
1211
1227
|
const permlink = sanitizePermlink(p3);
|
|
1212
1228
|
if (!isValidPermlink(permlink)) return match;
|
|
1213
|
-
if (SECTION_LIST.
|
|
1229
|
+
if (SECTION_LIST.includes(permlink)) {
|
|
1214
1230
|
const attrs = forApp ? `href="https://ecency.com/@${uu}/${permlink}"` : `href="/@${uu}/${permlink}"`;
|
|
1215
1231
|
return ` <a class="markdown-profile-link" ${attrs}>@${uu}/${permlink}</a>`;
|
|
1216
1232
|
} else {
|
|
@@ -1229,11 +1245,21 @@ function linkify(content, forApp) {
|
|
|
1229
1245
|
}
|
|
1230
1246
|
|
|
1231
1247
|
// src/methods/text.method.ts
|
|
1248
|
+
function hasAncestor(node, tagNames) {
|
|
1249
|
+
let current = node.parentNode;
|
|
1250
|
+
while (current) {
|
|
1251
|
+
if (tagNames.includes(current.nodeName.toLowerCase())) {
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
current = current.parentNode;
|
|
1255
|
+
}
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1232
1258
|
function text(node, forApp) {
|
|
1233
1259
|
if (!node || !node.parentNode) {
|
|
1234
1260
|
return;
|
|
1235
1261
|
}
|
|
1236
|
-
if (["a", "code"]
|
|
1262
|
+
if (hasAncestor(node, ["a", "code", "pre"])) {
|
|
1237
1263
|
return;
|
|
1238
1264
|
}
|
|
1239
1265
|
const nodeValue = node.nodeValue || "";
|