diff --git a/CHANGELOG.md b/CHANGELOG.md index c723c2e98..24401eaca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased [patch] + +> Development of this release was supported by [Reset Tech](https://www.reset.tech). + +### Fixed + +- Fix error messages when the start and end selectors of range selectors match elements on the page but the selected range or extracted content is empty + ## 10.3.1 - 2026-01-13 > Development of this release was supported by [Reset Tech](https://www.reset.tech). diff --git a/src/archivist/extract/index.js b/src/archivist/extract/index.js index 04da72497..a30080bd9 100644 --- a/src/archivist/extract/index.js +++ b/src/archivist/extract/index.js @@ -35,15 +35,16 @@ export async function extractFromHTML(sourceDocument) { const filteredDOM = await filter(webPageDOM, sourceDocument); const cleanedDOM = filteredDOM.remove(insignificantContentSelectors); const selectedDOM = cleanedDOM.select(contentSelectors); + const contentSelectorsDisplay = typeof contentSelectors === 'object' ? JSON.stringify(contentSelectors) : contentSelectors; if (!selectedDOM?.children.length) { - throw new Error(`The provided selector "${contentSelectors}" has no match in the web page at '${location}'. This could be due to elements being removed before content selection if "remove" and "select" selectors match the same content.`); + throw new Error(`The provided selector "${contentSelectorsDisplay}" has no match in the web page at '${location}'. This could be due to elements being removed before content selection if "remove" and "select" selectors match the same content.`); } const markdownContent = transformFromHTML(selectedDOM); if (!markdownContent) { - throw new Error(`The provided selector "${contentSelectors}" matches an empty content in the web page at '${location}'`); + throw new Error(`The provided selector "${contentSelectorsDisplay}" matches an empty content in the web page at '${location}'`); } return markdownContent;