mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-17 00:45:55 +08:00
fix: truncate svg in jsdom
This commit is contained in:
parent
4e5aff3332
commit
a08218506e
@ -39,6 +39,7 @@ export class JSDomControl extends AsyncService {
|
|||||||
const t0 = Date.now();
|
const t0 = Date.now();
|
||||||
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
||||||
const allNodes: Node[] = [];
|
const allNodes: Node[] = [];
|
||||||
|
jsdom.window.document.querySelectorAll('svg').forEach((x) => x.innerHTML = '');
|
||||||
if (options?.withIframe) {
|
if (options?.withIframe) {
|
||||||
jsdom.window.document.querySelectorAll('iframe[src],frame[src]').forEach((x) => {
|
jsdom.window.document.querySelectorAll('iframe[src],frame[src]').forEach((x) => {
|
||||||
const src = x.getAttribute('src');
|
const src = x.getAttribute('src');
|
||||||
@ -151,6 +152,7 @@ export class JSDomControl extends AsyncService {
|
|||||||
const extendedSnapshot = { ...snapshot } as ExtendedSnapshot;
|
const extendedSnapshot = { ...snapshot } as ExtendedSnapshot;
|
||||||
try {
|
try {
|
||||||
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
const jsdom = new JSDOM(snapshot.html, { url: snapshot.href, virtualConsole });
|
||||||
|
jsdom.window.document.querySelectorAll('svg').forEach((x) => x.innerHTML = '');
|
||||||
const links = Array.from(jsdom.window.document.querySelectorAll('a[href]'))
|
const links = Array.from(jsdom.window.document.querySelectorAll('a[href]'))
|
||||||
.map((x: any) => [x.getAttribute('href'), x.textContent.replace(/\s+/g, ' ').trim()])
|
.map((x: any) => [x.getAttribute('href'), x.textContent.replace(/\s+/g, ' ').trim()])
|
||||||
.map(([href, text]) => {
|
.map(([href, text]) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user