feedcanon 1.5.1 → 1.6.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/dist/defaults.cjs +5 -10
- package/dist/defaults.js +5 -10
- package/dist/exports.cjs +1 -0
- package/dist/exports.d.cts +2 -2
- package/dist/exports.d.ts +2 -2
- package/dist/exports.js +2 -2
- package/dist/types.d.cts +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/utils.cjs +7 -6
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +7 -7
- package/package.json +5 -6
package/dist/defaults.cjs
CHANGED
|
@@ -170,8 +170,7 @@ const defaultNormalizeOptions = {
|
|
|
170
170
|
stripEmptyQuery: true,
|
|
171
171
|
lowercaseQuery: false,
|
|
172
172
|
normalizeEncoding: true,
|
|
173
|
-
normalizeUnicode: true
|
|
174
|
-
convertToPunycode: true
|
|
173
|
+
normalizeUnicode: true
|
|
175
174
|
};
|
|
176
175
|
const defaultFetch = async (url, options) => {
|
|
177
176
|
const response = await fetch(url, {
|
|
@@ -241,8 +240,7 @@ const defaultTiers = [
|
|
|
241
240
|
stripQuery: true,
|
|
242
241
|
stripEmptyQuery: true,
|
|
243
242
|
normalizeEncoding: true,
|
|
244
|
-
normalizeUnicode: true
|
|
245
|
-
convertToPunycode: true
|
|
243
|
+
normalizeUnicode: true
|
|
246
244
|
},
|
|
247
245
|
{
|
|
248
246
|
stripProtocol: false,
|
|
@@ -256,8 +254,7 @@ const defaultTiers = [
|
|
|
256
254
|
stripQuery: false,
|
|
257
255
|
stripEmptyQuery: true,
|
|
258
256
|
normalizeEncoding: true,
|
|
259
|
-
normalizeUnicode: true
|
|
260
|
-
convertToPunycode: true
|
|
257
|
+
normalizeUnicode: true
|
|
261
258
|
},
|
|
262
259
|
{
|
|
263
260
|
stripProtocol: false,
|
|
@@ -271,8 +268,7 @@ const defaultTiers = [
|
|
|
271
268
|
stripQuery: false,
|
|
272
269
|
stripEmptyQuery: true,
|
|
273
270
|
normalizeEncoding: true,
|
|
274
|
-
normalizeUnicode: true
|
|
275
|
-
convertToPunycode: true
|
|
271
|
+
normalizeUnicode: true
|
|
276
272
|
},
|
|
277
273
|
{
|
|
278
274
|
stripProtocol: false,
|
|
@@ -286,8 +282,7 @@ const defaultTiers = [
|
|
|
286
282
|
stripQuery: false,
|
|
287
283
|
stripEmptyQuery: true,
|
|
288
284
|
normalizeEncoding: true,
|
|
289
|
-
normalizeUnicode: true
|
|
290
|
-
convertToPunycode: true
|
|
285
|
+
normalizeUnicode: true
|
|
291
286
|
}
|
|
292
287
|
];
|
|
293
288
|
//#endregion
|
package/dist/defaults.js
CHANGED
|
@@ -169,8 +169,7 @@ const defaultNormalizeOptions = {
|
|
|
169
169
|
stripEmptyQuery: true,
|
|
170
170
|
lowercaseQuery: false,
|
|
171
171
|
normalizeEncoding: true,
|
|
172
|
-
normalizeUnicode: true
|
|
173
|
-
convertToPunycode: true
|
|
172
|
+
normalizeUnicode: true
|
|
174
173
|
};
|
|
175
174
|
const defaultFetch = async (url, options) => {
|
|
176
175
|
const response = await fetch(url, {
|
|
@@ -240,8 +239,7 @@ const defaultTiers = [
|
|
|
240
239
|
stripQuery: true,
|
|
241
240
|
stripEmptyQuery: true,
|
|
242
241
|
normalizeEncoding: true,
|
|
243
|
-
normalizeUnicode: true
|
|
244
|
-
convertToPunycode: true
|
|
242
|
+
normalizeUnicode: true
|
|
245
243
|
},
|
|
246
244
|
{
|
|
247
245
|
stripProtocol: false,
|
|
@@ -255,8 +253,7 @@ const defaultTiers = [
|
|
|
255
253
|
stripQuery: false,
|
|
256
254
|
stripEmptyQuery: true,
|
|
257
255
|
normalizeEncoding: true,
|
|
258
|
-
normalizeUnicode: true
|
|
259
|
-
convertToPunycode: true
|
|
256
|
+
normalizeUnicode: true
|
|
260
257
|
},
|
|
261
258
|
{
|
|
262
259
|
stripProtocol: false,
|
|
@@ -270,8 +267,7 @@ const defaultTiers = [
|
|
|
270
267
|
stripQuery: false,
|
|
271
268
|
stripEmptyQuery: true,
|
|
272
269
|
normalizeEncoding: true,
|
|
273
|
-
normalizeUnicode: true
|
|
274
|
-
convertToPunycode: true
|
|
270
|
+
normalizeUnicode: true
|
|
275
271
|
},
|
|
276
272
|
{
|
|
277
273
|
stripProtocol: false,
|
|
@@ -285,8 +281,7 @@ const defaultTiers = [
|
|
|
285
281
|
stripQuery: false,
|
|
286
282
|
stripEmptyQuery: true,
|
|
287
283
|
normalizeEncoding: true,
|
|
288
|
-
normalizeUnicode: true
|
|
289
|
-
convertToPunycode: true
|
|
284
|
+
normalizeUnicode: true
|
|
290
285
|
}
|
|
291
286
|
];
|
|
292
287
|
//#endregion
|
package/dist/exports.cjs
CHANGED
|
@@ -17,4 +17,5 @@ exports.fixMalformedProtocol = require_utils.fixMalformedProtocol;
|
|
|
17
17
|
exports.normalizeUrl = require_utils.normalizeUrl;
|
|
18
18
|
exports.resolveFeedProtocol = require_utils.resolveFeedProtocol;
|
|
19
19
|
exports.resolveUrl = require_utils.resolveUrl;
|
|
20
|
+
exports.upgradeProtocol = require_utils.upgradeProtocol;
|
|
20
21
|
exports.wordpressProbe = require_wordpress.wordpressProbe;
|
package/dist/exports.d.cts
CHANGED
|
@@ -4,5 +4,5 @@ import { findCanonical } from "./index.cjs";
|
|
|
4
4
|
import { wordpressProbe } from "./probes/wordpress.cjs";
|
|
5
5
|
import { bloggerRewrite } from "./rewrites/blogger.cjs";
|
|
6
6
|
import { feedburnerRewrite } from "./rewrites/feedburner.cjs";
|
|
7
|
-
import { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl } from "./utils.cjs";
|
|
8
|
-
export { type DefaultParserResult, type ExistsFn, type FetchFn, type FetchFnOptions, type FetchFnResponse, type FindCanonicalOptions, type NormalizeOptions, type OnExistsFn, type OnFetchFn, type OnMatchFn, type ParserAdapter, type Probe, type Rewrite, type Tier, addMissingProtocol, bloggerRewrite, defaultFetch, defaultParser, defaultStrippedParams, defaultTiers, feedburnerRewrite, findCanonical, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, wordpressProbe };
|
|
7
|
+
import { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol } from "./utils.cjs";
|
|
8
|
+
export { type DefaultParserResult, type ExistsFn, type FetchFn, type FetchFnOptions, type FetchFnResponse, type FindCanonicalOptions, type NormalizeOptions, type OnExistsFn, type OnFetchFn, type OnMatchFn, type ParserAdapter, type Probe, type Rewrite, type Tier, addMissingProtocol, bloggerRewrite, defaultFetch, defaultParser, defaultStrippedParams, defaultTiers, feedburnerRewrite, findCanonical, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol, wordpressProbe };
|
package/dist/exports.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ import { findCanonical } from "./index.js";
|
|
|
4
4
|
import { wordpressProbe } from "./probes/wordpress.js";
|
|
5
5
|
import { bloggerRewrite } from "./rewrites/blogger.js";
|
|
6
6
|
import { feedburnerRewrite } from "./rewrites/feedburner.js";
|
|
7
|
-
import { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl } from "./utils.js";
|
|
8
|
-
export { type DefaultParserResult, type ExistsFn, type FetchFn, type FetchFnOptions, type FetchFnResponse, type FindCanonicalOptions, type NormalizeOptions, type OnExistsFn, type OnFetchFn, type OnMatchFn, type ParserAdapter, type Probe, type Rewrite, type Tier, addMissingProtocol, bloggerRewrite, defaultFetch, defaultParser, defaultStrippedParams, defaultTiers, feedburnerRewrite, findCanonical, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, wordpressProbe };
|
|
7
|
+
import { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol } from "./utils.js";
|
|
8
|
+
export { type DefaultParserResult, type ExistsFn, type FetchFn, type FetchFnOptions, type FetchFnResponse, type FindCanonicalOptions, type NormalizeOptions, type OnExistsFn, type OnFetchFn, type OnMatchFn, type ParserAdapter, type Probe, type Rewrite, type Tier, addMissingProtocol, bloggerRewrite, defaultFetch, defaultParser, defaultStrippedParams, defaultTiers, feedburnerRewrite, findCanonical, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol, wordpressProbe };
|
package/dist/exports.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl } from "./utils.js";
|
|
1
|
+
import { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol } from "./utils.js";
|
|
2
2
|
import { defaultFetch, defaultParser, defaultStrippedParams, defaultTiers } from "./defaults.js";
|
|
3
3
|
import { findCanonical } from "./index.js";
|
|
4
4
|
import { wordpressProbe } from "./probes/wordpress.js";
|
|
5
5
|
import { bloggerRewrite } from "./rewrites/blogger.js";
|
|
6
6
|
import { feedburnerRewrite } from "./rewrites/feedburner.js";
|
|
7
|
-
export { addMissingProtocol, bloggerRewrite, defaultFetch, defaultParser, defaultStrippedParams, defaultTiers, feedburnerRewrite, findCanonical, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, wordpressProbe };
|
|
7
|
+
export { addMissingProtocol, bloggerRewrite, defaultFetch, defaultParser, defaultStrippedParams, defaultTiers, feedburnerRewrite, findCanonical, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol, wordpressProbe };
|
package/dist/types.d.cts
CHANGED
|
@@ -31,7 +31,6 @@ type NormalizeOptions = {
|
|
|
31
31
|
lowercaseQuery?: boolean;
|
|
32
32
|
normalizeEncoding?: boolean;
|
|
33
33
|
normalizeUnicode?: boolean;
|
|
34
|
-
convertToPunycode?: boolean;
|
|
35
34
|
};
|
|
36
35
|
type Tier = Omit<NormalizeOptions, 'stripQueryParams'>;
|
|
37
36
|
type OnFetchFn<TResponse extends FetchFnResponse = FetchFnResponse> = (data: {
|
package/dist/types.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ type NormalizeOptions = {
|
|
|
31
31
|
lowercaseQuery?: boolean;
|
|
32
32
|
normalizeEncoding?: boolean;
|
|
33
33
|
normalizeUnicode?: boolean;
|
|
34
|
-
convertToPunycode?: boolean;
|
|
35
34
|
};
|
|
36
35
|
type Tier = Omit<NormalizeOptions, 'stripQueryParams'>;
|
|
37
36
|
type OnFetchFn<TResponse extends FetchFnResponse = FetchFnResponse> = (data: {
|
package/dist/utils.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_defaults = require("./defaults.cjs");
|
|
2
|
-
let node_url = require("node:url");
|
|
3
2
|
let entities = require("entities");
|
|
4
3
|
//#region src/utils.ts
|
|
5
4
|
const strippedParamsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -15,9 +14,10 @@ const ipv4Regex = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
|
15
14
|
const ipv6Regex = /^([0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}$/i;
|
|
16
15
|
const safePathCharsRegex = /[a-zA-Z0-9._~!$&'()*+,;=:@-]/;
|
|
17
16
|
const httpsLetterRegex = /s/i;
|
|
18
|
-
const nonAsciiHostnameRegex = /[^a-z0-9.:-]/;
|
|
19
17
|
const protocolPrefixRegex = /^https?:\/\//;
|
|
20
18
|
const wwwPrefixRegex = /^www\./;
|
|
19
|
+
const httpProtocolRegex = /^http:\/\//i;
|
|
20
|
+
const httpsProtocolRegex = /^https:\/\//i;
|
|
21
21
|
const validUrlRegex = /^https?:\/\/(?:www\.|[a-vx-z0-9])/i;
|
|
22
22
|
const doubledProtocolRegex = /^\/?[htps]{2,7}[:\s=.\\/]+([htps]{2,7})[:\s=.\\/]+[.,:/]*(www[./]+)?/i;
|
|
23
23
|
const singleMalformedRegex = /^\/?(?:h[htps():]{1,10}|t{1,2}ps?)[:\s=.\\/]+[.,:/]*(www[./]+)?/i;
|
|
@@ -79,6 +79,10 @@ const addMissingProtocol = (url, protocol = "https") => {
|
|
|
79
79
|
if (firstChar === " " || firstChar === " " || firstChar === "\n") return url;
|
|
80
80
|
return `${protocol}://${url}`;
|
|
81
81
|
};
|
|
82
|
+
const upgradeProtocol = (url, protocol = "https") => {
|
|
83
|
+
if (protocol === "https") return url.replace(httpProtocolRegex, "https://");
|
|
84
|
+
return url.replace(httpsProtocolRegex, "http://");
|
|
85
|
+
};
|
|
82
86
|
const resolveUrl = (url, base) => {
|
|
83
87
|
if (url.startsWith("#") && !base) return;
|
|
84
88
|
let resolvedUrl;
|
|
@@ -115,10 +119,6 @@ const normalizeUrl = (url, options = require_defaults.defaultNormalizeOptions) =
|
|
|
115
119
|
parsed.hostname = parsed.hostname.normalize("NFC");
|
|
116
120
|
parsed.pathname = parsed.pathname.normalize("NFC");
|
|
117
121
|
}
|
|
118
|
-
if (options.convertToPunycode && nonAsciiHostnameRegex.test(parsed.hostname)) {
|
|
119
|
-
const ascii = (0, node_url.domainToASCII)(parsed.hostname);
|
|
120
|
-
if (ascii) parsed.hostname = ascii;
|
|
121
|
-
}
|
|
122
122
|
if (options.stripAuthentication) {
|
|
123
123
|
parsed.username = "";
|
|
124
124
|
parsed.password = "";
|
|
@@ -212,3 +212,4 @@ exports.neutralizeUrls = neutralizeUrls;
|
|
|
212
212
|
exports.normalizeUrl = normalizeUrl;
|
|
213
213
|
exports.resolveFeedProtocol = resolveFeedProtocol;
|
|
214
214
|
exports.resolveUrl = resolveUrl;
|
|
215
|
+
exports.upgradeProtocol = upgradeProtocol;
|
package/dist/utils.d.cts
CHANGED
|
@@ -4,7 +4,8 @@ import { NormalizeOptions } from "./types.cjs";
|
|
|
4
4
|
declare const fixMalformedProtocol: (url: string) => string;
|
|
5
5
|
declare const resolveFeedProtocol: (url: string, protocol?: "http" | "https") => string;
|
|
6
6
|
declare const addMissingProtocol: (url: string, protocol?: "http" | "https") => string;
|
|
7
|
+
declare const upgradeProtocol: (url: string, protocol?: "http" | "https") => string;
|
|
7
8
|
declare const resolveUrl: (url: string, base?: string) => string | undefined;
|
|
8
9
|
declare const normalizeUrl: (url: string, options?: NormalizeOptions) => string;
|
|
9
10
|
//#endregion
|
|
10
|
-
export { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl };
|
|
11
|
+
export { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol };
|
package/dist/utils.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { NormalizeOptions } from "./types.js";
|
|
|
4
4
|
declare const fixMalformedProtocol: (url: string) => string;
|
|
5
5
|
declare const resolveFeedProtocol: (url: string, protocol?: "http" | "https") => string;
|
|
6
6
|
declare const addMissingProtocol: (url: string, protocol?: "http" | "https") => string;
|
|
7
|
+
declare const upgradeProtocol: (url: string, protocol?: "http" | "https") => string;
|
|
7
8
|
declare const resolveUrl: (url: string, base?: string) => string | undefined;
|
|
8
9
|
declare const normalizeUrl: (url: string, options?: NormalizeOptions) => string;
|
|
9
10
|
//#endregion
|
|
10
|
-
export { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl };
|
|
11
|
+
export { addMissingProtocol, fixMalformedProtocol, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol };
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defaultNormalizeOptions } from "./defaults.js";
|
|
2
|
-
import { domainToASCII } from "node:url";
|
|
3
2
|
import { decodeHTML } from "entities";
|
|
4
3
|
//#region src/utils.ts
|
|
5
4
|
const strippedParamsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -15,9 +14,10 @@ const ipv4Regex = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
|
15
14
|
const ipv6Regex = /^([0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}$/i;
|
|
16
15
|
const safePathCharsRegex = /[a-zA-Z0-9._~!$&'()*+,;=:@-]/;
|
|
17
16
|
const httpsLetterRegex = /s/i;
|
|
18
|
-
const nonAsciiHostnameRegex = /[^a-z0-9.:-]/;
|
|
19
17
|
const protocolPrefixRegex = /^https?:\/\//;
|
|
20
18
|
const wwwPrefixRegex = /^www\./;
|
|
19
|
+
const httpProtocolRegex = /^http:\/\//i;
|
|
20
|
+
const httpsProtocolRegex = /^https:\/\//i;
|
|
21
21
|
const validUrlRegex = /^https?:\/\/(?:www\.|[a-vx-z0-9])/i;
|
|
22
22
|
const doubledProtocolRegex = /^\/?[htps]{2,7}[:\s=.\\/]+([htps]{2,7})[:\s=.\\/]+[.,:/]*(www[./]+)?/i;
|
|
23
23
|
const singleMalformedRegex = /^\/?(?:h[htps():]{1,10}|t{1,2}ps?)[:\s=.\\/]+[.,:/]*(www[./]+)?/i;
|
|
@@ -79,6 +79,10 @@ const addMissingProtocol = (url, protocol = "https") => {
|
|
|
79
79
|
if (firstChar === " " || firstChar === " " || firstChar === "\n") return url;
|
|
80
80
|
return `${protocol}://${url}`;
|
|
81
81
|
};
|
|
82
|
+
const upgradeProtocol = (url, protocol = "https") => {
|
|
83
|
+
if (protocol === "https") return url.replace(httpProtocolRegex, "https://");
|
|
84
|
+
return url.replace(httpsProtocolRegex, "http://");
|
|
85
|
+
};
|
|
82
86
|
const resolveUrl = (url, base) => {
|
|
83
87
|
if (url.startsWith("#") && !base) return;
|
|
84
88
|
let resolvedUrl;
|
|
@@ -115,10 +119,6 @@ const normalizeUrl = (url, options = defaultNormalizeOptions) => {
|
|
|
115
119
|
parsed.hostname = parsed.hostname.normalize("NFC");
|
|
116
120
|
parsed.pathname = parsed.pathname.normalize("NFC");
|
|
117
121
|
}
|
|
118
|
-
if (options.convertToPunycode && nonAsciiHostnameRegex.test(parsed.hostname)) {
|
|
119
|
-
const ascii = domainToASCII(parsed.hostname);
|
|
120
|
-
if (ascii) parsed.hostname = ascii;
|
|
121
|
-
}
|
|
122
122
|
if (options.stripAuthentication) {
|
|
123
123
|
parsed.username = "";
|
|
124
124
|
parsed.password = "";
|
|
@@ -203,4 +203,4 @@ const neutralizeUrls = (text, urls) => {
|
|
|
203
203
|
return text.replace(new RegExp(`https?://(?:www\\.)?${hostPattern}(?=[/"]|\\\\")(/)?`, "g"), "/").replace(trailingSlashRegex, "$1$2");
|
|
204
204
|
};
|
|
205
205
|
//#endregion
|
|
206
|
-
export { addMissingProtocol, applyProbes, applyRewrites, createSignature, fixMalformedProtocol, neutralizeUrls, normalizeUrl, resolveFeedProtocol, resolveUrl };
|
|
206
|
+
export { addMissingProtocol, applyProbes, applyRewrites, createSignature, fixMalformedProtocol, neutralizeUrls, normalizeUrl, resolveFeedProtocol, resolveUrl, upgradeProtocol };
|
package/package.json
CHANGED
|
@@ -55,14 +55,13 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"entities": "^7.0.1",
|
|
58
|
-
"feedsmith": "^2.9.
|
|
59
|
-
"typescript": "^6.0.2"
|
|
58
|
+
"feedsmith": "^2.9.4"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
|
-
"@types/bun": "^1.3.
|
|
63
|
-
"kvalita": "1.
|
|
64
|
-
"tsdown": "^0.
|
|
61
|
+
"@types/bun": "^1.3.13",
|
|
62
|
+
"kvalita": "1.13.0",
|
|
63
|
+
"tsdown": "^0.22.0",
|
|
65
64
|
"vitepress": "^2.0.0-alpha.17"
|
|
66
65
|
},
|
|
67
|
-
"version": "1.
|
|
66
|
+
"version": "1.6.0"
|
|
68
67
|
}
|