Clean up parameters
This commit is contained in:
parent
93c919afa4
commit
70a8125fa8
1 changed files with 9 additions and 3 deletions
12
src/index.ts
12
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<Report> {
|
|||
};
|
||||
for (const el of dom) {
|
||||
if (el.type === "tag") {
|
||||
recurseElement(report, content, el);
|
||||
recurseElement({ report, rawHtml: content }, el);
|
||||
}
|
||||
}
|
||||
resolve(report);
|
||||
|
|
Loading…
Reference in a new issue