html-snapshots 6.0.0 → 6.1.0
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/lib/common/index.js +31 -0
- package/lib/common/sitemap/sitemap.js +1 -2
- package/lib/input-generators/_base.js +2 -2
- package/lib/input-generators/array.js +1 -2
- package/package.json +14 -3
- package/.nvmrc +0 -1
- package/eslint.config.js +0 -24
package/lib/common/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2025, Alex Grant, LocalNerve, contributors
|
|
5
5
|
* Licensed under the MIT license.
|
|
6
6
|
*/
|
|
7
|
+
const { parse: legacyUrlParser } = require("node:url"); // eslint-disable-line n/no-deprecated-api
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Ensures that options at least contains propties and values from must
|
|
@@ -26,6 +27,7 @@ function ensure (options, must) {
|
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Simple test for url
|
|
30
|
+
* Tests for an absolute url string
|
|
29
31
|
*
|
|
30
32
|
* If you can think of a more approriate test for this use case,
|
|
31
33
|
* please let me know in the issues...
|
|
@@ -40,6 +42,34 @@ function isUrl (obj) {
|
|
|
40
42
|
return false;
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Parse a string url to a URL object
|
|
47
|
+
* Fallback to legacy parser
|
|
48
|
+
*
|
|
49
|
+
* @param {String} inputUrl - a url to parse.
|
|
50
|
+
*/
|
|
51
|
+
function parseUrl (inputUrl) {
|
|
52
|
+
let parsedUrl;
|
|
53
|
+
try {
|
|
54
|
+
if (isUrl(inputUrl)) {
|
|
55
|
+
parsedUrl = new URL(inputUrl);
|
|
56
|
+
} else {
|
|
57
|
+
parsedUrl = new URL(inputUrl, "bogus://bogus");
|
|
58
|
+
if (parsedUrl.protocol === "bogus:") {
|
|
59
|
+
parsedUrl.protocol = "";
|
|
60
|
+
}
|
|
61
|
+
if (parsedUrl.hostname === "bogus") {
|
|
62
|
+
parsedUrl.hostname = "";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// add legacy auth property
|
|
66
|
+
parsedUrl.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
67
|
+
} catch {
|
|
68
|
+
parsedUrl = legacyUrlParser(inputUrl);
|
|
69
|
+
}
|
|
70
|
+
return parsedUrl;
|
|
71
|
+
}
|
|
72
|
+
|
|
43
73
|
/**
|
|
44
74
|
* Simple test for a function
|
|
45
75
|
*
|
|
@@ -194,5 +224,6 @@ module.exports = {
|
|
|
194
224
|
isFunction,
|
|
195
225
|
isObject,
|
|
196
226
|
once,
|
|
227
|
+
parseUrl,
|
|
197
228
|
prependMsgToErr
|
|
198
229
|
};
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
const fs = require("node:fs");
|
|
12
12
|
const util = require("node:util");
|
|
13
13
|
const path = require("node:path");
|
|
14
|
-
const urlm = require("node:url");
|
|
15
14
|
const zlib = require("node:zlib");
|
|
16
15
|
const xml2js = require("xml2js");
|
|
17
16
|
const smi = require("./sitemap-index");
|
|
@@ -114,7 +113,7 @@ function parse (options, document, callback) {
|
|
|
114
113
|
|
|
115
114
|
if (process) {
|
|
116
115
|
// if sitemap is malformed, just blow up
|
|
117
|
-
url =
|
|
116
|
+
url = common.parseUrl(urlNode.loc[0]);
|
|
118
117
|
if (!base.input(
|
|
119
118
|
{ ...options,
|
|
120
119
|
...{
|
|
@@ -153,7 +153,7 @@ function prepOptions (options, listener) {
|
|
|
153
153
|
* @returns {String} The 'path' part of the file output path.
|
|
154
154
|
*/
|
|
155
155
|
function getOutputPath (options, page, parse) {
|
|
156
|
-
const pagePart =
|
|
156
|
+
const pagePart = common.parseUrl(page);
|
|
157
157
|
// if outputPath was normalized with an object, let the key passthru
|
|
158
158
|
let outputPath = options.outputPath(page, true);
|
|
159
159
|
|
|
@@ -164,7 +164,7 @@ function getOutputPath (options, page, parse) {
|
|
|
164
164
|
|
|
165
165
|
// if the outputPath is really still a url, fix it to path+hash
|
|
166
166
|
if (common.isUrl(outputPath)) {
|
|
167
|
-
outputPath = pagePart.
|
|
167
|
+
outputPath = `${pagePart.pathname}${pagePart.search}${pagePart.hash ? pagePart.hash : ""}`;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// if the caller wants the url parse output, return it
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* Licensed under the MIT license.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const urlm = require("node:url");
|
|
12
11
|
const common = require("../common");
|
|
13
12
|
const base = require("./_base");
|
|
14
13
|
|
|
@@ -38,7 +37,7 @@ function generateInput (options) {
|
|
|
38
37
|
const result = new Promise((resolve, reject) => {
|
|
39
38
|
if (Array.isArray(options.source)) {
|
|
40
39
|
const all = options.source.every(sourceUrl => {
|
|
41
|
-
const url =
|
|
40
|
+
const url = common.parseUrl(sourceUrl);
|
|
42
41
|
const opts = Object.assign({}, options, {
|
|
43
42
|
protocol: url.protocol,
|
|
44
43
|
auth: url.auth,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-snapshots",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Alex Grant",
|
|
6
6
|
"email": "alex@localnerve.com",
|
|
@@ -41,6 +41,16 @@
|
|
|
41
41
|
"type": "git",
|
|
42
42
|
"url": "https://github.com/localnerve/html-snapshots.git"
|
|
43
43
|
},
|
|
44
|
+
"funding": [
|
|
45
|
+
{
|
|
46
|
+
"type": "github",
|
|
47
|
+
"url": "https://github.com/sponsors/localnerve"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"type": "paypal",
|
|
51
|
+
"url": "https://www.paypal.com/ncp/payment/DHCB5GUYMGX5U"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
44
54
|
"keywords": [
|
|
45
55
|
"SEO",
|
|
46
56
|
"html",
|
|
@@ -54,13 +64,14 @@
|
|
|
54
64
|
"dependencies": {
|
|
55
65
|
"async": "3.2.6",
|
|
56
66
|
"async-lock": "1.4.1",
|
|
57
|
-
"playwright": "1.
|
|
67
|
+
"playwright": "1.61.0",
|
|
58
68
|
"puppeteer": "25.1.0",
|
|
59
69
|
"xml2js": "0.6.2"
|
|
60
70
|
},
|
|
61
71
|
"devDependencies": {
|
|
62
72
|
"@eslint/js": "^10.0.1",
|
|
63
|
-
"eslint": "^10.
|
|
73
|
+
"eslint": "^10.5.0",
|
|
74
|
+
"eslint-plugin-n": "18.1.0",
|
|
64
75
|
"express": "^5.2.1",
|
|
65
76
|
"globals": "^17.6.0",
|
|
66
77
|
"server-destroy": "^1.0.1",
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
24.16
|
package/eslint.config.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const js = require("@eslint/js");
|
|
2
|
-
const globals = require("globals");
|
|
3
|
-
|
|
4
|
-
module.exports = [{
|
|
5
|
-
ignores: [
|
|
6
|
-
"tmp/**",
|
|
7
|
-
"coverage/**",
|
|
8
|
-
"examples/**",
|
|
9
|
-
"test/suites/html-snapshots/server/**"
|
|
10
|
-
]
|
|
11
|
-
}, {
|
|
12
|
-
languageOptions: {
|
|
13
|
-
sourceType: "commonjs",
|
|
14
|
-
globals: {
|
|
15
|
-
...globals.node
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
files: ["**/*.js"],
|
|
19
|
-
rules: {
|
|
20
|
-
...js.configs.recommended.rules,
|
|
21
|
-
"no-console": 0,
|
|
22
|
-
"quotes": ["error", "double"]
|
|
23
|
-
}
|
|
24
|
-
}];
|