Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
fix: WEC failed to extract links from some websites
Browse files Browse the repository at this point in the history
error: Cannot read properties of undefined (reading 'startsWith')
  • Loading branch information
rriemann committed May 29, 2024
1 parent 9c36f24 commit 974e08a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD

* fix: WEC failed to extract links from some websites, error: Cannot read properties of undefined (reading 'startsWith')

## 2.1.2 / 2024-04-25

* feature: support PDF output with `website-evidence-reporter` using chromium (brings the benefit of adding page title and page numbers)
Expand Down
12 changes: 6 additions & 6 deletions collector/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const {
async function collectLinks(page, logger) {
// get all links from page
const links_all_with_duplicates = await page.evaluate(() => {
return Array.from(document.querySelectorAll("a[href]"), (a) => {
return {
href: a.href.toString().split("#").shift(), // link without fragment
inner_text: a.innerText,
inner_html: a.innerHTML.trim(),
}
return Array.from(document.querySelectorAll("a[href]")).map( (a) => {
return {
href: a.href.toString().split("#").shift(), // link without fragment
inner_text: a.innerText,
inner_html: a.innerHTML.trim(),
}
});
});

Expand Down

0 comments on commit 974e08a

Please sign in to comment.