diff --git a/src/index.ts b/src/index.ts index dfee391..41faa23 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { }; for (const el of dom) { if (el.type === "tag") { - recurseElement(report, content, el); + recurseElement({ report, rawHtml: content }, el); } } resolve(report);