unprint 0.18.14 → 0.18.16
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 +27 -21
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -374,37 +374,43 @@ function prefixUrl(urlPath, originUrl, customOptions) {
|
|
|
374
374
|
...customOptions,
|
|
375
375
|
};
|
|
376
376
|
|
|
377
|
-
|
|
378
|
-
// this is already a complete URL
|
|
379
|
-
return urlPath;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (options.protocol && /^\/\//.test(urlPath)) {
|
|
383
|
-
return `${options.protocol.replace(/:$/, '')}:${urlPath}`; // allow protocol to be defined either as 'https' or 'https:'
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (!originUrl) {
|
|
387
|
-
return urlPath;
|
|
388
|
-
}
|
|
377
|
+
const origin = originUrl?.replace(/^.*?:/, `${options.protocol}:`);
|
|
389
378
|
|
|
390
|
-
|
|
379
|
+
return new URL(urlPath, origin).href;
|
|
380
|
+
}
|
|
391
381
|
|
|
392
|
-
|
|
393
|
-
|
|
382
|
+
// legacy argument
|
|
383
|
+
function getQueryUrlArgs(selectorOrOptions, customOptions) {
|
|
384
|
+
if (customOptions) {
|
|
385
|
+
return {
|
|
386
|
+
selector: selectorOrOptions,
|
|
387
|
+
customOptions,
|
|
388
|
+
};
|
|
394
389
|
}
|
|
395
390
|
|
|
396
|
-
if (
|
|
397
|
-
return
|
|
391
|
+
if (typeof selectorOrOptions === 'string') {
|
|
392
|
+
return {
|
|
393
|
+
selector: selectorOrOptions,
|
|
394
|
+
customOptions: null,
|
|
395
|
+
};
|
|
398
396
|
}
|
|
399
397
|
|
|
400
|
-
if (
|
|
401
|
-
return
|
|
398
|
+
if (!selectorOrOptions) {
|
|
399
|
+
return {
|
|
400
|
+
selector: 'a',
|
|
401
|
+
customOptions: null,
|
|
402
|
+
};
|
|
402
403
|
}
|
|
403
404
|
|
|
404
|
-
return
|
|
405
|
+
return {
|
|
406
|
+
selector: 'a',
|
|
407
|
+
customOptions: selectorOrOptions,
|
|
408
|
+
};
|
|
405
409
|
}
|
|
406
410
|
|
|
407
|
-
function queryUrl(context,
|
|
411
|
+
function queryUrl(context, ...args) {
|
|
412
|
+
const { selector, customOptions } = getQueryUrlArgs(...args);
|
|
413
|
+
|
|
408
414
|
const options = {
|
|
409
415
|
...context.options,
|
|
410
416
|
attribute: 'href',
|