single-file-cli 2.0.46 → 2.0.47

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.46";
1
+ export const version = "2.0.47";
package/options.js CHANGED
@@ -81,6 +81,7 @@ const OPTIONS_INFO = {
81
81
  "dump-content": { description: "Dump the content of the processed page in the console ('true' when running in Docker)", type: "boolean" },
82
82
  "emulate-media-feature": { description: "Emulate a media feature. The syntax is <name>:<value>, e.g. \"prefers-color-scheme:dark\"", type: "string[]" },
83
83
  "error-file": { description: "Path of the file where to save the error messages", type: "string" },
84
+ "error-traces-disabled": { description: "Remove error stack traces in the error messages", type: "boolean", defaultValue: true },
84
85
  "filename-template": { description: "Template used to generate the output filename (see help page of the extension for more info)", type: "string", defaultValue: "%if-empty<{page-title}|No title> ({date-locale} {time-locale}).{filename-extension}" },
85
86
  "filename-conflict-action": { description: "Action when the filename is conflicting with existing one on the filesystem. The possible values are \"uniquify\" (default), \"overwrite\" and \"skip\"", type: "string", defaultValue: "uniquify" },
86
87
  "filename-replacement-character": { description: "The character used for replacing invalid characters in filenames", type: "string", defaultValue: "_" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-cli",
3
- "version": "2.0.46",
3
+ "version": "2.0.47",
4
4
  "description": "SingleFile CLI",
5
5
  "author": "Gildas Lormeau",
6
6
  "engines": {
@@ -184,29 +184,31 @@ function testMaxDepth(task) {
184
184
 
185
185
  async function createTask(url, options, parentTask, rootTask) {
186
186
  url = parentTask ? rewriteURL(url, options.crawlRemoveURLFragment, options.crawlRewriteRules) : url;
187
- if (!VALID_URL_TEST.test(url)) {
188
- try {
189
- url = url.replace(/\\/g, "/");
190
- url = url.replace(/#/g, "%23");
191
- const baseURL = await path.toFileUrl((await Deno.cwd()) + path.SEPARATOR);
192
- url = new URL(url, baseURL).href;
193
- } catch (error) {
194
- throw new Error("Invalid URL or file path: " + url, { cause: error });
187
+ if (url) {
188
+ if (!VALID_URL_TEST.test(url)) {
189
+ try {
190
+ url = url.replace(/\\/g, "/");
191
+ url = url.replace(/#/g, "%23");
192
+ const baseURL = await path.toFileUrl((await Deno.cwd()) + path.SEPARATOR);
193
+ url = new URL(url, baseURL).href;
194
+ } catch (error) {
195
+ throw new Error("Invalid URL or file path: " + url, { cause: error });
196
+ }
195
197
  }
198
+ const isInnerLink = rootTask && url.startsWith(getHostURL(rootTask.url));
199
+ const rootBaseURIMatch = rootTask && rootTask.url.match(/(.*?)[^/]*$/);
200
+ const isChild = isInnerLink && rootBaseURIMatch && rootBaseURIMatch[1] && url.startsWith(rootBaseURIMatch[1]);
201
+ return {
202
+ url,
203
+ isInnerLink,
204
+ isChild,
205
+ originalUrl: url,
206
+ rootBaseURI: rootBaseURIMatch && rootBaseURIMatch[1],
207
+ depth: parentTask ? parentTask.depth + 1 : 0,
208
+ externalLinkDepth: isInnerLink ? -1 : parentTask ? parentTask.externalLinkDepth + 1 : -1,
209
+ options
210
+ };
196
211
  }
197
- const isInnerLink = rootTask && url.startsWith(getHostURL(rootTask.url));
198
- const rootBaseURIMatch = rootTask && rootTask.url.match(/(.*?)[^/]*$/);
199
- const isChild = isInnerLink && rootBaseURIMatch && rootBaseURIMatch[1] && url.startsWith(rootBaseURIMatch[1]);
200
- return {
201
- url,
202
- isInnerLink,
203
- isChild,
204
- originalUrl: url,
205
- rootBaseURI: rootBaseURIMatch && rootBaseURIMatch[1],
206
- depth: parentTask ? parentTask.depth + 1 : 0,
207
- externalLinkDepth: isInnerLink ? -1 : parentTask ? parentTask.externalLinkDepth + 1 : -1,
208
- options
209
- };
210
212
  }
211
213
 
212
214
  async function saveTasks() {
@@ -269,7 +271,7 @@ async function capturePage(options) {
269
271
  }
270
272
  return pageData;
271
273
  } catch (error) {
272
- const message = "URL: " + options.url + "\nStack: " + error.stack + "\n";
274
+ const message = "URL: " + options.url + (options.errorTracesDisabled ? "" : "\nStack: " + error.stack) + "\n";
273
275
  if (options.errorFile) {
274
276
  await writeTextFile(options.errorFile, message, { append: true });
275
277
  } else {