Skip to content

Commit 660c02c

Browse files
authored
Fix range selector display in error messages (#1228)
2 parents 43e16be + 45442b6 commit 660c02c

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
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).
44

5+
## Unreleased [patch]
6+
7+
> Development of this release was supported by [Reset Tech](https://www.reset.tech).
8+
9+
### Fixed
10+
11+
- 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
12+
513
## 10.3.1 - 2026-01-13
614

715
> Development of this release was supported by [Reset Tech](https://www.reset.tech).

src/archivist/extract/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ export async function extractFromHTML(sourceDocument) {
3535
const filteredDOM = await filter(webPageDOM, sourceDocument);
3636
const cleanedDOM = filteredDOM.remove(insignificantContentSelectors);
3737
const selectedDOM = cleanedDOM.select(contentSelectors);
38+
const contentSelectorsDisplay = typeof contentSelectors === 'object' ? JSON.stringify(contentSelectors) : contentSelectors;
3839

3940
if (!selectedDOM?.children.length) {
40-
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.`);
41+
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.`);
4142
}
4243

4344
const markdownContent = transformFromHTML(selectedDOM);
4445

4546
if (!markdownContent) {
46-
throw new Error(`The provided selector "${contentSelectors}" matches an empty content in the web page at '${location}'`);
47+
throw new Error(`The provided selector "${contentSelectorsDisplay}" matches an empty content in the web page at '${location}'`);
4748
}
4849

4950
return markdownContent;

0 commit comments

Comments
 (0)