unprint 0.18.13 → 0.18.15

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app.js +33 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.18.13",
3
+ "version": "0.18.15",
4
4
  "description": "Simplify common web scraping tasks while staying in control of the data.",
5
5
  "main": "src/app.js",
6
6
  "scripts": {},
package/src/app.js CHANGED
@@ -404,7 +404,38 @@ function prefixUrl(urlPath, originUrl, customOptions) {
404
404
  return `${origin}/${urlPath}`;
405
405
  }
406
406
 
407
- function queryUrl(context, selector = 'a', customOptions) {
407
+ // legacy argument
408
+ function getQueryUrlArgs(selectorOrOptions, customOptions) {
409
+ if (customOptions) {
410
+ return {
411
+ selector: selectorOrOptions,
412
+ customOptions,
413
+ };
414
+ }
415
+
416
+ if (typeof selectorOrOptions === 'string') {
417
+ return {
418
+ selector: selectorOrOptions,
419
+ customOptions: null,
420
+ };
421
+ }
422
+
423
+ if (!selectorOrOptions) {
424
+ return {
425
+ selector: 'a',
426
+ customOptions: null,
427
+ };
428
+ }
429
+
430
+ return {
431
+ selector: 'a',
432
+ customOptions: selectorOrOptions,
433
+ };
434
+ }
435
+
436
+ function queryUrl(context, ...args) {
437
+ const { selector, customOptions } = getQueryUrlArgs(...args);
438
+
408
439
  const options = {
409
440
  ...context.options,
410
441
  attribute: 'href',
@@ -736,7 +767,7 @@ function extractDate(dateString, format, customOptions) {
736
767
  }
737
768
 
738
769
  const options = {
739
- match: /((\d{1,4}[/-]\d{1,2}[/-]\d{1,4})|(\w+\s+\d{1,2},?\s+\d{4})|(\d{1,2}-\w+-\d{2,4}))((T|\s+)\d{1,2}:\d{2}(:\d{2})?)?/g, // matches any of 01-01-1970, 1970-01-01, 01-Jan-70 and January 1, 1970 with optional 00:00[:00] time
770
+ match: /((\d{1,4}[/-]\d{1,2}[/-]\d{1,4})|(\w+\s+\d{1,2}([a-z]{2})?,?\s+\d{4})|(\d{1,2}-\w+-\d{2,4}))((T|\s+)\d{1,2}:\d{2}(:\d{2})?)?/gi, // matches any of 01-01-1970, 1970-01-01, 01-Jan-70 and January 1, 1970 with optional 00:00[:00] time
740
771
  matchIndex: 0,
741
772
  timezone: 'UTC',
742
773
  ...customOptions,