single-file-cli 2.0.66 → 2.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "2.0.66";
1
+ export const version = "2.0.68";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-cli",
3
- "version": "2.0.66",
3
+ "version": "2.0.68",
4
4
  "description": "SingleFile CLI",
5
5
  "author": "Gildas Lormeau",
6
6
  "engines": {
@@ -162,7 +162,7 @@ async function runNextTask() {
162
162
  task.filename = pageData.filename;
163
163
  if (options.crawlLinks && testMaxDepth(task)) {
164
164
  const urls = pageData.links;
165
- let newTasks = await Promise.all(urls.map(url => createTask(url, options, task, tasks[0])));
165
+ let newTasks = await Promise.all(urls.map(url => createTask(url, options, task, task.rootTaskURL || task.url)));
166
166
  newTasks = newTasks.filter(task => task &&
167
167
  testMaxDepth(task) &&
168
168
  !tasks.find(otherTask => otherTask.url == task.url) &&
@@ -182,7 +182,7 @@ function testMaxDepth(task) {
182
182
  (options.crawlExternalLinksMaxDepth == 0 || task.externalLinkDepth < options.crawlExternalLinksMaxDepth);
183
183
  }
184
184
 
185
- async function createTask(url, options, parentTask, rootTask) {
185
+ async function createTask(url, options, parentTask, rootTaskURL) {
186
186
  url = parentTask ? rewriteURL(url, options.crawlRemoveURLFragment, options.crawlRewriteRules) : url;
187
187
  if (url) {
188
188
  if (!VALID_URL_TEST.test(url)) {
@@ -195,15 +195,15 @@ async function createTask(url, options, parentTask, rootTask) {
195
195
  throw new Error("Invalid URL or file path: " + url, { cause: error });
196
196
  }
197
197
  }
198
- const isInnerLink = rootTask && url.startsWith(getHostURL(rootTask.url));
199
- const rootBaseURIMatch = rootTask && rootTask.url.match(/(.*?)[^/]*$/);
198
+ const isInnerLink = rootTaskURL && url.startsWith(getHostURL(rootTaskURL));
199
+ const rootBaseURIMatch = rootTaskURL && rootTaskURL.match(/(.*?)[^/]*$/);
200
200
  const isChild = isInnerLink && rootBaseURIMatch && rootBaseURIMatch[1] && url.startsWith(rootBaseURIMatch[1]);
201
201
  return {
202
202
  url,
203
203
  isInnerLink,
204
204
  isChild,
205
205
  originalUrl: url,
206
- rootBaseURI: rootBaseURIMatch && rootBaseURIMatch[1],
206
+ rootTaskURL,
207
207
  depth: parentTask ? parentTask.depth + 1 : 0,
208
208
  externalLinkDepth: isInnerLink ? -1 : parentTask ? parentTask.externalLinkDepth + 1 : -1,
209
209
  options