unprint 0.10.2 → 0.10.4
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 +1 -1
- package/src/app.js +8 -6
- package/tests/index.html +1 -0
- package/tests/init.js +1 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { JSDOM, VirtualConsole } = require('jsdom');
|
|
4
|
+
const http = require('http');
|
|
5
|
+
const https = require('https');
|
|
4
6
|
const axios = require('axios').default;
|
|
5
7
|
const moment = require('moment-timezone');
|
|
6
8
|
const merge = require('deepmerge');
|
|
@@ -601,12 +603,12 @@ function extractDuration(durationString, match) {
|
|
|
601
603
|
}
|
|
602
604
|
|
|
603
605
|
function extractTimestamp(durationString) {
|
|
604
|
-
const timestampMatch = durationString?.match(/(\d
|
|
606
|
+
const timestampMatch = durationString?.match(/(\d+\s*H)?.*(\d+\s*M)?.*(\d+\s*(S|$))?/i)?.[0];
|
|
605
607
|
|
|
606
608
|
if (timestampMatch) {
|
|
607
|
-
const hours = timestampMatch
|
|
608
|
-
const minutes = timestampMatch
|
|
609
|
-
const seconds = timestampMatch
|
|
609
|
+
const hours = timestampMatch.match(/(\d+)\s*H/i)?.[1] || 0;
|
|
610
|
+
const minutes = timestampMatch.match(/(\d+)\s*M/i)?.[1] || 0;
|
|
611
|
+
const seconds = timestampMatch.match(/(\d+)\s*(s(ec\w*)?)|$/i)?.[1] || 0;
|
|
610
612
|
|
|
611
613
|
return (Number(hours) * 3600) + (Number(minutes) * 60) + Number(seconds);
|
|
612
614
|
}
|
|
@@ -791,8 +793,8 @@ async function request(url, body, customOptions = {}, method = 'GET') {
|
|
|
791
793
|
...options,
|
|
792
794
|
timeout: options.timeout,
|
|
793
795
|
signal: options.abortSignal,
|
|
794
|
-
httpAgent: options.
|
|
795
|
-
httpsAgent: options.
|
|
796
|
+
httpAgent: new http.Agent({ ...options.agent }),
|
|
797
|
+
httpsAgent: new https.Agent({ ...options.agent }),
|
|
796
798
|
});
|
|
797
799
|
|
|
798
800
|
if (!(res.status >= 200 && res.status < 300)) {
|
package/tests/index.html
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
<div id="duration">01:15:33</div>
|
|
34
34
|
<div id="timestamp">PT1H34M18S</div>
|
|
35
|
+
<div id="timestring">1 hour 40 minutes 5 seconds</div>
|
|
35
36
|
|
|
36
37
|
<img class="image" src="https://i.redd.it/vn9h981hlx281.png">
|
|
37
38
|
<img class="image" src="https://i.redd.it/1s22dsrqy0181.jpg">
|
package/tests/init.js
CHANGED
|
@@ -21,6 +21,7 @@ async function initTest() {
|
|
|
21
21
|
console.log('date xpath', res.context.query.date('//div[contains(text(), "Today:")]', 'MMM DD, YYYY'));
|
|
22
22
|
console.log('duration', res.context.query.duration('#duration'));
|
|
23
23
|
console.log('timestamp', res.context.query.duration('#timestamp'));
|
|
24
|
+
console.log('timestring', res.context.query.duration('#timestring'));
|
|
24
25
|
console.log('number', res.context.query.number('.number'));
|
|
25
26
|
console.log('numbers', res.context.query.numbers('.number'));
|
|
26
27
|
console.log('number indexed', res.context.query.number('.number', { match: /(\d+)/, matchIndex: 1 }));
|