feedcanon 2.0.0-next.2 → 2.0.0-next.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/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/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
@@ -16,6 +16,8 @@ const safePathCharsRegex = /[a-zA-Z0-9._~!$&'()*+,;=:@-]/;
16
16
  const httpsLetterRegex = /s/i;
17
17
  const protocolPrefixRegex = /^https?:\/\//;
18
18
  const wwwPrefixRegex = /^www\./;
19
+ const httpProtocolRegex = /^http:\/\//i;
20
+ const httpsProtocolRegex = /^https:\/\//i;
19
21
  const validUrlRegex = /^https?:\/\/(?:www\.|[a-vx-z0-9])/i;
20
22
  const doubledProtocolRegex = /^\/?[htps]{2,7}[:\s=.\\/]+([htps]{2,7})[:\s=.\\/]+[.,:/]*(www[./]+)?/i;
21
23
  const singleMalformedRegex = /^\/?(?:h[htps():]{1,10}|t{1,2}ps?)[:\s=.\\/]+[.,:/]*(www[./]+)?/i;
@@ -77,6 +79,10 @@ const addMissingProtocol = (url, protocol = "https") => {
77
79
  if (firstChar === " " || firstChar === " " || firstChar === "\n") return url;
78
80
  return `${protocol}://${url}`;
79
81
  };
82
+ const upgradeProtocol = (url, protocol = "https") => {
83
+ if (protocol === "https") return url.replace(httpProtocolRegex, "https://");
84
+ return url.replace(httpsProtocolRegex, "http://");
85
+ };
80
86
  const resolveUrl = (url, base) => {
81
87
  if (url.startsWith("#") && !base) return;
82
88
  let resolvedUrl;
@@ -197,4 +203,4 @@ const neutralizeUrls = (text, urls) => {
197
203
  return text.replace(new RegExp(`https?://(?:www\\.)?${hostPattern}(?=[/"]|\\\\")(/)?`, "g"), "/").replace(trailingSlashRegex, "$1$2");
198
204
  };
199
205
  //#endregion
200
- 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
@@ -42,14 +42,17 @@
42
42
  "docs:build": "vitepress build docs"
43
43
  },
44
44
  "dependencies": {
45
- "entities": "^8.0.0",
46
- "feedsmith": "^3.0.0-beta.1"
45
+ "entities": "^8.0.0"
46
+ },
47
+ "peerDependencies": {
48
+ "feedsmith": "^3.0.0-beta.4"
47
49
  },
48
50
  "devDependencies": {
49
- "@types/bun": "^1.3.11",
50
- "kvalita": "1.12.4",
51
- "tsdown": "^0.21.7",
51
+ "@types/bun": "^1.3.13",
52
+ "feedsmith": "^3.0.0-beta.4",
53
+ "kvalita": "^1.13.0",
54
+ "tsdown": "^0.22.0",
52
55
  "vitepress": "^2.0.0-alpha.17"
53
56
  },
54
- "version": "2.0.0-next.2"
57
+ "version": "2.0.0-next.4"
55
58
  }