Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
5 changes: 3 additions & 2 deletions src/archivist/extract/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading