unprint 0.11.11 → 0.11.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.11.11",
3
+ "version": "0.11.13",
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
@@ -217,11 +217,23 @@ function extractNumber(rawNumberString, customOptions) {
217
217
  : rawNumberString.replace(',', '');
218
218
 
219
219
  if (numberString && options.match) {
220
- return Number(numberString.match(options.match)?.[options.matchIndex]) || null;
220
+ const number = Number(numberString.match(options.match)?.[options.matchIndex]);
221
+
222
+ if (Number.isNaN(number)) {
223
+ return null;
224
+ }
225
+
226
+ return number;
221
227
  }
222
228
 
223
229
  if (numberString) {
224
- return Number(numberString) || null;
230
+ const number = Number(numberString);
231
+
232
+ if (Number.isNaN(number)) {
233
+ return null;
234
+ }
235
+
236
+ return number;
225
237
  }
226
238
 
227
239
  return null;
@@ -481,7 +493,7 @@ function removeStyleFunctionSpaces(el) {
481
493
  // jsdom appears to have a bug where it ignores inline CSS attributes set to a function() containing spaces, e.g. url( image.png )
482
494
  el.setAttribute('style', el.getAttribute('style')
483
495
  .replace(/\(\s+(.*)\s+\)/g, (match, cssArgs) => `(${cssArgs})`)
484
- .replace(/\)[\w\s-]+;/g, ');'));
496
+ .replace(/\)[\w\s/-]+;/g, ');'));
485
497
  }
486
498
 
487
499
  function queryStyle(context, selector, customOptions) {
package/tests/index.html CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  <!-- deliberate space in url( ) to test JSDOM's quirky handling of this -->
46
46
  <div class="style" style="background-image: url( https://i.imgur.com/eDQmLys.jpg ); color: red;"></div>
47
- <div class="background" style="background: url(https://i.imgur.com/xFHbuDL.jpeg) 0 0 no-repeat; color: green;"></div>
47
+ <div class="background" style="background: url(https://i.imgur.com/xFHbuDL.jpeg) 0 0/contain no-repeat; color: green;"></div>
48
48
  <div class="style" style="margin: 1rem; color: blue;"></div>
49
49
 
50
50
  <video id="video" poster="https://i.imgur.com/eDQmLys.jpg"><source src="https://i.imgur.com/eDQmLys.mp4"></video>