unprint 0.8.0 → 0.8.1
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 +14 -2
- package/tests/index.html +3 -1
- package/tests/init.js +1 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -283,9 +283,20 @@ function queryUrl(context, selector = 'a', customOptions) {
|
|
|
283
283
|
};
|
|
284
284
|
|
|
285
285
|
const url = queryContent(context, selector, options);
|
|
286
|
-
const curatedUrl = prefixUrl(url, options.origin, customOptions);
|
|
287
286
|
|
|
288
|
-
return
|
|
287
|
+
return prefixUrl(url, options.origin, customOptions);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function queryUrls(context, selector = 'a', customOptions) {
|
|
291
|
+
const options = {
|
|
292
|
+
...context.options,
|
|
293
|
+
attribute: 'href',
|
|
294
|
+
...customOptions,
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const urls = queryContents(context, selector, options);
|
|
298
|
+
|
|
299
|
+
return urls.map((url) => prefixUrl(url, options.origin, customOptions));
|
|
289
300
|
}
|
|
290
301
|
|
|
291
302
|
function getImageUrl(context, selector, options) {
|
|
@@ -577,6 +588,7 @@ const queryFns = {
|
|
|
577
588
|
sourceSet: querySourceSet,
|
|
578
589
|
srcSet: querySourceSet,
|
|
579
590
|
url: queryUrl,
|
|
591
|
+
urls: queryUrls,
|
|
580
592
|
video: queryVideo,
|
|
581
593
|
videos: queryVideos,
|
|
582
594
|
};
|
package/tests/index.html
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
<li class="number">789.0</li>
|
|
21
21
|
</ul>
|
|
22
22
|
|
|
23
|
-
<a id="link" href="http://localhost:3101/html">Get
|
|
23
|
+
<a id="link" class="link" href="http://localhost:3101/html">Get URL</a>
|
|
24
|
+
<a id="link" class="link" href="http://localhost:3101/html">Get URL</a>
|
|
25
|
+
|
|
24
26
|
<a id="path" href="/json">Get data</a>
|
|
25
27
|
<a id="relativePath" href="./json">Get data</a>
|
|
26
28
|
|
package/tests/init.js
CHANGED
|
@@ -26,6 +26,7 @@ async function initTest() {
|
|
|
26
26
|
console.log('data', res.context.query.json('#json'));
|
|
27
27
|
console.log('items', res.context.query.contents('.item'));
|
|
28
28
|
console.log('link', res.context.query.url('#link'));
|
|
29
|
+
console.log('links', res.context.query.urls('.link'));
|
|
29
30
|
console.log('image', res.context.query.img('.image'));
|
|
30
31
|
console.log('images', res.context.query.imgs('.image'));
|
|
31
32
|
console.log('srcset', res.context.query.sourceSet('.srcset'));
|