unprint 0.10.4 → 0.10.6

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.10.4",
3
+ "version": "0.10.6",
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
@@ -191,15 +191,15 @@ function queryDatasets(context, selector, dataAttribute, customOptions) {
191
191
  return targets.map((target) => target.dataset[dataAttribute]);
192
192
  }
193
193
 
194
- const defaultNumberRegexp = /\d+(\.\d+)?/;
194
+ const defaultNumberRegexp = /\d+([.,]\d+)?/;
195
195
 
196
196
  function matchNumberString(numberString, options) {
197
197
  if (numberString && options.match) {
198
- return Number(numberString.match(options.match)?.[options.matchIndex]) || null;
198
+ return Number(numberString.match(options.match)?.[options.matchIndex]?.replace(',', '.')) || null;
199
199
  }
200
200
 
201
201
  if (numberString) {
202
- return Number(numberString) || null;
202
+ return Number(numberString.replace(',', '.')) || null;
203
203
  }
204
204
 
205
205
  return null;
package/tests/index.html CHANGED
@@ -17,7 +17,8 @@
17
17
  <ul id="numbers">
18
18
  <li class="number">123</li>
19
19
  <li class="number">234.56</li>
20
- <li class="number">789.0</li>
20
+ <li class="number">789,30</li>
21
+ <li class="number">200,0</li>
21
22
  </ul>
22
23
 
23
24
  <a id="link" class="link" href="http://localhost:3101/html">Get URL</a>