feedcanon 1.4.0 → 1.4.2

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/utils.cjs CHANGED
@@ -52,10 +52,11 @@ const resolveFeedProtocol = (url, protocol = "https") => {
52
52
  return url;
53
53
  };
54
54
  const addMissingProtocol = (url, protocol = "https") => {
55
- try {
56
- const parsed = new URL(url);
57
- if (!parsed.protocol.includes(".") && parsed.protocol !== "localhost:") return url;
58
- } catch {}
55
+ const colonIndex = url.indexOf(":");
56
+ if (colonIndex > 0) {
57
+ const beforeColon = url.slice(0, colonIndex);
58
+ if (!beforeColon.includes(".") && !beforeColon.includes("/") && beforeColon !== "localhost") return url;
59
+ }
59
60
  if (url.startsWith("//") && !url.startsWith("///")) try {
60
61
  const parsed = new URL(`${protocol}:${url}`);
61
62
  const hostname = parsed.hostname;
@@ -110,7 +111,7 @@ const normalizeUrl = (url, options = require_defaults.defaultNormalizeOptions) =
110
111
  parsed.hostname = parsed.hostname.normalize("NFC");
111
112
  parsed.pathname = parsed.pathname.normalize("NFC");
112
113
  }
113
- if (options.convertToPunycode) {
114
+ if (options.convertToPunycode && /[^a-z0-9.:-]/.test(parsed.hostname)) {
114
115
  const ascii = (0, node_url.domainToASCII)(parsed.hostname);
115
116
  if (ascii) parsed.hostname = ascii;
116
117
  }
@@ -138,7 +139,7 @@ const normalizeUrl = (url, options = require_defaults.defaultNormalizeOptions) =
138
139
  parsed.search = "";
139
140
  for (const [key, value] of entries) parsed.searchParams.append(key.toLowerCase(), value.toLowerCase());
140
141
  }
141
- if (options.sortQueryParams) parsed.searchParams.sort();
142
+ if (options.sortQueryParams && parsed.search) parsed.searchParams.sort();
142
143
  if (options.stripEmptyQuery && parsed.href.endsWith("?")) parsed.search = "";
143
144
  let result = parsed.href;
144
145
  if (options.stripRootSlash && result === `${parsed.origin}/`) result = parsed.origin;
package/dist/utils.js CHANGED
@@ -52,10 +52,11 @@ const resolveFeedProtocol = (url, protocol = "https") => {
52
52
  return url;
53
53
  };
54
54
  const addMissingProtocol = (url, protocol = "https") => {
55
- try {
56
- const parsed = new URL(url);
57
- if (!parsed.protocol.includes(".") && parsed.protocol !== "localhost:") return url;
58
- } catch {}
55
+ const colonIndex = url.indexOf(":");
56
+ if (colonIndex > 0) {
57
+ const beforeColon = url.slice(0, colonIndex);
58
+ if (!beforeColon.includes(".") && !beforeColon.includes("/") && beforeColon !== "localhost") return url;
59
+ }
59
60
  if (url.startsWith("//") && !url.startsWith("///")) try {
60
61
  const parsed = new URL(`${protocol}:${url}`);
61
62
  const hostname = parsed.hostname;
@@ -110,7 +111,7 @@ const normalizeUrl = (url, options = defaultNormalizeOptions) => {
110
111
  parsed.hostname = parsed.hostname.normalize("NFC");
111
112
  parsed.pathname = parsed.pathname.normalize("NFC");
112
113
  }
113
- if (options.convertToPunycode) {
114
+ if (options.convertToPunycode && /[^a-z0-9.:-]/.test(parsed.hostname)) {
114
115
  const ascii = domainToASCII(parsed.hostname);
115
116
  if (ascii) parsed.hostname = ascii;
116
117
  }
@@ -138,7 +139,7 @@ const normalizeUrl = (url, options = defaultNormalizeOptions) => {
138
139
  parsed.search = "";
139
140
  for (const [key, value] of entries) parsed.searchParams.append(key.toLowerCase(), value.toLowerCase());
140
141
  }
141
- if (options.sortQueryParams) parsed.searchParams.sort();
142
+ if (options.sortQueryParams && parsed.search) parsed.searchParams.sort();
142
143
  if (options.stripEmptyQuery && parsed.href.endsWith("?")) parsed.search = "";
143
144
  let result = parsed.href;
144
145
  if (options.stripRootSlash && result === `${parsed.origin}/`) result = parsed.origin;
package/package.json CHANGED
@@ -55,13 +55,13 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "entities": "^7.0.1",
58
- "feedsmith": "^2.9.0"
58
+ "feedsmith": "^2.9.1"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/bun": "^1.3.10",
62
62
  "kvalita": "1.10.0",
63
- "tsdown": "^0.21.0",
63
+ "tsdown": "^0.21.4",
64
64
  "vitepress": "^1.6.4"
65
65
  },
66
- "version": "1.4.0"
66
+ "version": "1.4.2"
67
67
  }