Store parsed DOM in InputHandler
This commit is contained in:
parent
66ae5226b7
commit
e5ccbfe434
@ -7,6 +7,7 @@ export class HandlerInput {
|
|||||||
private requestUrl: URL;
|
private requestUrl: URL;
|
||||||
private engine?: string;
|
private engine?: string;
|
||||||
private redirectPath: string;
|
private redirectPath: string;
|
||||||
|
private dom?: JSDOM;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: string,
|
data: string,
|
||||||
@ -23,9 +24,13 @@ export class HandlerInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseDom(): JSDOM {
|
parseDom(): JSDOM {
|
||||||
const dom = new JSDOM(this.data, { url: this.url });
|
if (this.dom) {
|
||||||
|
return this.dom;
|
||||||
|
}
|
||||||
|
|
||||||
const links = dom.window.document.getElementsByTagName("a");
|
this.dom = new JSDOM(this.data, { url: this.url });
|
||||||
|
|
||||||
|
const links = this.dom.window.document.getElementsByTagName("a");
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
try {
|
try {
|
||||||
link.href = generateProxyUrl(
|
link.href = generateProxyUrl(
|
||||||
@ -39,7 +44,7 @@ export class HandlerInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dom;
|
return this.dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUrl(): string {
|
getUrl(): string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user