Clean up parameters

This commit is contained in:
Cat /dev/Nulo 2022-11-25 22:09:41 -03:00
parent 93c919afa4
commit 70a8125fa8

View file

@ -19,7 +19,13 @@ interface Report {
things: Thing[];
}
function recurseElement(report: Report, rawHtml: string, el: Element) {
interface Page {
report: Report;
rawHtml: string;
}
function recurseElement(page: Page, el: Element) {
const { report, rawHtml } = page;
if (el.name === "a") {
if (el.attribs.href !== undefined) {
if (isHttp(el.attribs.href)) {
@ -53,7 +59,7 @@ function recurseElement(report: Report, rawHtml: string, el: Element) {
for (const child of el.children) {
if (child.type === "tag") {
recurseElement(report, rawHtml, child);
recurseElement(page, child);
}
}
}
@ -104,7 +110,7 @@ function processFile(content: string): Promise<Report> {
};
for (const el of dom) {
if (el.type === "tag") {
recurseElement(report, content, el);
recurseElement({ report, rawHtml: content }, el);
}
}
resolve(report);