@ecency/render-helper 2.5.20 → 2.5.22
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 +39 -13
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +39 -14
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +39 -13
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/node/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var xmldom = require('@xmldom/xmldom');
|
|
4
4
|
var he2 = require('he');
|
|
5
5
|
var xss = require('xss');
|
|
6
|
-
var multihash = require('multihashes');
|
|
7
6
|
var querystring = require('querystring');
|
|
8
7
|
var lruCache = require('lru-cache');
|
|
9
8
|
var remarkable = require('remarkable');
|
|
@@ -33,7 +32,6 @@ function _interopNamespace(e) {
|
|
|
33
32
|
|
|
34
33
|
var he2__default = /*#__PURE__*/_interopDefault(he2);
|
|
35
34
|
var xss__default = /*#__PURE__*/_interopDefault(xss);
|
|
36
|
-
var multihash__default = /*#__PURE__*/_interopDefault(multihash);
|
|
37
35
|
var querystring__default = /*#__PURE__*/_interopDefault(querystring);
|
|
38
36
|
var htmlparser2__namespace = /*#__PURE__*/_interopNamespace(htmlparser2);
|
|
39
37
|
var domSerializerModule__namespace = /*#__PURE__*/_interopNamespace(domSerializerModule);
|
|
@@ -101,15 +99,15 @@ var VIMEO_EMBED_REGEX = /https:\/\/player\.vimeo\.com\/video\/([0-9]+)(?:$|[?#])
|
|
|
101
99
|
var BITCHUTE_REGEX = /^(?:https?:\/\/)?(?:www\.)?bitchute\.com\/(?:video|embed)\/([a-z0-9]+)/i;
|
|
102
100
|
var D_TUBE_REGEX = /(https?:\/\/d\.tube\/#!\/v\/)(\w+)\/(\w+)/g;
|
|
103
101
|
var D_TUBE_REGEX2 = /(https?:\/\/d\.tube\/v\/)(\w+)\/(\w+)/g;
|
|
104
|
-
var D_TUBE_EMBED_REGEX = /^https:\/\/emb
|
|
102
|
+
var D_TUBE_EMBED_REGEX = /^https:\/\/emb\.d\.tube\/#!\/[^/?#]+\/[^/?#]+(?:$|[?#])/i;
|
|
105
103
|
var TWITCH_REGEX = /https?:\/\/(?:www\.)?twitch\.tv\/(?:(videos)\/)?([a-zA-Z0-9][\w]{3,24})/i;
|
|
106
|
-
var DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr
|
|
107
|
-
var TRUVVL_REGEX = /^https?:\/\/embed
|
|
108
|
-
var LBRY_REGEX = /^(https?:)?\/\/lbry
|
|
104
|
+
var DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr\.in\/file\/dapplr-videos\/.*/i;
|
|
105
|
+
var TRUVVL_REGEX = /^https?:\/\/embed\.truvvl\.com\/(@[\w.\d-]+)\/(.*)/i;
|
|
106
|
+
var LBRY_REGEX = /^(https?:)?\/\/lbry\.tv\/\$\/embed\/[^?#]+(?:$|[?#])/i;
|
|
109
107
|
var ODYSEE_REGEX = /^(https?:)?\/\/odysee\.com\/(?:\$|%24)\/embed\/[^?#]+(?:$|[?#])/i;
|
|
110
108
|
var SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i;
|
|
111
109
|
var SKATEHYPE_EMBED_REGEX = /^(https?:)?\/\/(www\.)?skatehype\.com\/ifplay\.php\?v=\d+(?:$|[&#])/i;
|
|
112
|
-
var ARCH_REGEX = /^(https?:)?\/\/archive
|
|
110
|
+
var ARCH_REGEX = /^(https?:)?\/\/archive\.org\/embed\/[^/?#]+(?:$|[?#])/i;
|
|
113
111
|
var SPEAK_REGEX = /(?:https?:\/\/(?:(?:play\.)?3speak\.([a-z]+)\/watch\?v=)|(?:(?:play\.)?3speak\.([a-z]+)\/embed\?v=))([A-Za-z0-9_\-\.\/]+)(&.*)?/i;
|
|
114
112
|
var SPEAK_EMBED_REGEX = /^(https?:)?\/\/(?:play\.)?3speak\.([a-z]+)\/(?:embed|watch)\?.+$/i;
|
|
115
113
|
var SPEAK_AUDIO_REGEX = /https?:\/\/audio\.3speak\.tv\/play\?[^\s]+/i;
|
|
@@ -128,7 +126,6 @@ var LOOM_REGEX = /^(https?:)?\/\/www\.loom\.com\/share\/([^/?#]+)(?:$|[?#])/i;
|
|
|
128
126
|
var LOOM_EMBED_REGEX = /^(https?:)?\/\/www\.loom\.com\/embed\/([^/?#]+)(?:$|[?#])/i;
|
|
129
127
|
var AUREAL_EMBED_REGEX = /^(https?:)?\/\/(www\.)?(?:aureal-embed)\.web\.app\/([0-9]+)(?:$|[?#])/i;
|
|
130
128
|
var ENTITY_REGEX = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/ig;
|
|
131
|
-
var SECTION_REGEX = /\B(\#[\da-zA-Z-_]+\b)(?!;)/i;
|
|
132
129
|
var ID_WHITELIST = /^[A-Za-z][-A-Za-z0-9_]*$/;
|
|
133
130
|
|
|
134
131
|
// src/consts/allowed-attributes.const.ts
|
|
@@ -571,10 +568,35 @@ function removeChildNodes(node) {
|
|
|
571
568
|
}
|
|
572
569
|
var proxyBase = "https://i.ecency.com";
|
|
573
570
|
var urlHashCache = new lruCache.LRUCache({ max: 500 });
|
|
571
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
572
|
+
function base58Encode(bytes) {
|
|
573
|
+
if (bytes.length === 0) return "";
|
|
574
|
+
const digits = [0];
|
|
575
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
576
|
+
let carry = bytes[i];
|
|
577
|
+
for (let j = 0; j < digits.length; j++) {
|
|
578
|
+
carry += digits[j] << 8;
|
|
579
|
+
digits[j] = carry % 58;
|
|
580
|
+
carry = carry / 58 | 0;
|
|
581
|
+
}
|
|
582
|
+
while (carry > 0) {
|
|
583
|
+
digits.push(carry % 58);
|
|
584
|
+
carry = carry / 58 | 0;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
let out = "";
|
|
588
|
+
for (let k = 0; k < bytes.length && bytes[k] === 0; k++) out += BASE58_ALPHABET[0];
|
|
589
|
+
for (let q = digits.length - 1; q >= 0; q--) out += BASE58_ALPHABET[digits[q]];
|
|
590
|
+
return out;
|
|
591
|
+
}
|
|
592
|
+
function utf8Bytes(url) {
|
|
593
|
+
if (typeof TextEncoder !== "undefined") return new TextEncoder().encode(url);
|
|
594
|
+
return Uint8Array.from(Buffer.from(url, "utf8"));
|
|
595
|
+
}
|
|
574
596
|
function getUrlHash(url) {
|
|
575
597
|
const cached = urlHashCache.get(url);
|
|
576
598
|
if (cached) return cached;
|
|
577
|
-
const hash =
|
|
599
|
+
const hash = base58Encode(utf8Bytes(url));
|
|
578
600
|
urlHashCache.set(url, hash);
|
|
579
601
|
return hash;
|
|
580
602
|
}
|
|
@@ -902,10 +924,6 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
902
924
|
if (!href) {
|
|
903
925
|
return;
|
|
904
926
|
}
|
|
905
|
-
const className = el.getAttribute("class");
|
|
906
|
-
if (className && (["markdown-author-link", "markdown-tag-link"].includes(className) || className.includes("er-author") || className.includes("er-tag"))) {
|
|
907
|
-
return;
|
|
908
|
-
}
|
|
909
927
|
const trimmed = href.trim().replace(/[\t\n\r\f\v\0]/g, "").toLowerCase();
|
|
910
928
|
const isSafeScheme = /^(https?|mailto|hive|tel|web\+[a-z0-9.+-]+):/i.test(trimmed);
|
|
911
929
|
const isRelative = /^(\/\/|\/[^/]?|#|\?|[a-z0-9._\-]+(\/|$))/i.test(trimmed);
|
|
@@ -913,6 +931,13 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
913
931
|
el.removeAttribute("href");
|
|
914
932
|
return;
|
|
915
933
|
}
|
|
934
|
+
const className = el.getAttribute("class");
|
|
935
|
+
if (className && (["markdown-author-link", "markdown-tag-link"].includes(className) || className.includes("er-author") || className.includes("er-tag"))) {
|
|
936
|
+
if (el.getAttribute("target")) {
|
|
937
|
+
el.setAttribute("rel", getExternalLinkRel(seoContext));
|
|
938
|
+
}
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
916
941
|
if (href.match(IMG_REGEX) && href.trim().replace(/&/g, "&") === getSerializedInnerHTML(el).trim().replace(/&/g, "&")) {
|
|
917
942
|
const isLCP = false;
|
|
918
943
|
const imgHTML = createImageHTML(href, isLCP, forApp);
|
|
@@ -1510,7 +1535,7 @@ function a(el, forApp, parentDomain = "ecency.com", seoContext, renderOptions) {
|
|
|
1510
1535
|
}
|
|
1511
1536
|
el.removeAttribute("href");
|
|
1512
1537
|
} else {
|
|
1513
|
-
const matchS = href.
|
|
1538
|
+
const matchS = href.trim().startsWith("#");
|
|
1514
1539
|
if (matchS) {
|
|
1515
1540
|
el.setAttribute("class", "markdown-internal-link");
|
|
1516
1541
|
} else {
|