Spaces:
Build error
Build error
fix: truncate svg in jsdom
Browse files
backend/functions/src/services/jsdom.ts
CHANGED
|
@@ -39,6 +39,7 @@ export class JSDomControl extends AsyncService {
|
|
| 39 |
const t0 = Date.now();
|
| 40 |
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
| 41 |
const allNodes: Node[] = [];
|
|
|
|
| 42 |
if (options?.withIframe) {
|
| 43 |
jsdom.window.document.querySelectorAll('iframe[src],frame[src]').forEach((x) => {
|
| 44 |
const src = x.getAttribute('src');
|
|
@@ -151,6 +152,7 @@ export class JSDomControl extends AsyncService {
|
|
| 151 |
const extendedSnapshot = { ...snapshot } as ExtendedSnapshot;
|
| 152 |
try {
|
| 153 |
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
|
|
|
| 154 |
const links = Array.from(jsdom.window.document.querySelectorAll('a[href]'))
|
| 155 |
.map((x: any) => [x.getAttribute('href'), x.textContent.replace(/\s+/g, ' ').trim()])
|
| 156 |
.map(([href, text]) => {
|
|
|
|
| 39 |
const t0 = Date.now();
|
| 40 |
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
| 41 |
const allNodes: Node[] = [];
|
| 42 |
+
jsdom.window.document.querySelectorAll('svg').forEach((x) => x.innerHTML = '');
|
| 43 |
if (options?.withIframe) {
|
| 44 |
jsdom.window.document.querySelectorAll('iframe[src],frame[src]').forEach((x) => {
|
| 45 |
const src = x.getAttribute('src');
|
|
|
|
| 152 |
const extendedSnapshot = { ...snapshot } as ExtendedSnapshot;
|
| 153 |
try {
|
| 154 |
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
| 155 |
+
jsdom.window.document.querySelectorAll('svg').forEach((x) => x.innerHTML = '');
|
| 156 |
const links = Array.from(jsdom.window.document.querySelectorAll('a[href]'))
|
| 157 |
.map((x: any) => [x.getAttribute('href'), x.textContent.replace(/\s+/g, ' ').trim()])
|
| 158 |
.map(([href, text]) => {
|