feedsmith 2.7.0 β†’ 2.8.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/README.md CHANGED
@@ -22,22 +22,22 @@ Feedsmith offers universal and format‑specific parsers that maintain the origi
22
22
 
23
23
  ### Core
24
24
 
25
- * **Comprehensive support** 🎯 β€” Supports all major feed formats and namespaces.
26
- * **Preserves structure** πŸ“¦ β€” Parsed feed object maintains the original feed structure making it easy to access the data.
27
- * **Smart namespace handling** 🧠 β€” Normalizes custom namespace prefixes to standard ones (e.g., `<custom:creator>` becomes `dc.creator`).
28
- * **Parsing & generating** πŸ”© β€” Use one package for both parsing and generating feeds.
25
+ * **Comprehensive support** β€” Supports all major feed formats and namespaces.
26
+ * **Preserves structure** β€” Parsed feed object maintains the original feed structure making it easy to access the data.
27
+ * **Smart namespace handling** β€” Normalizes custom namespace prefixes to standard ones (e.g., `<custom:creator>` becomes `dc.creator`).
28
+ * **Parsing & generating** β€” Use one package for both parsing and generating feeds.
29
29
 
30
30
  ### Leniency
31
- * **Normalizes legacy elements** ✨ β€” Upgrades feed elements to their modern equivalents so that you never need to worry about reading feeds in older formats.
32
- * **CaSe INSENsiTive** 🐍 β€” Handles fields and attributes in any case (lowercase, uppercase, mixed).
33
- * **Namespace URI tolerance** πŸ”§ β€” Accepts non-official namespace URIs (HTTPS variants, case variations, trailing slashes, whitespace).
34
- * **Forgiving** 🀝 β€” Gracefully handles malformed or incomplete feeds and extracts valid data. This makes it suitable for use with real-world feeds that may not strictly follow specifications.
31
+ * **Normalizes legacy elements** β€” Upgrades feed elements to their modern equivalents so that you never need to worry about reading feeds in older formats.
32
+ * **CaSe INSENsiTive** β€” Handles fields and attributes in any case (lowercase, uppercase, mixed).
33
+ * **Namespace URI tolerance** β€” Accepts non-official namespace URIs (HTTPS variants, case variations, trailing slashes, whitespace).
34
+ * **Forgiving** β€” Gracefully handles malformed or incomplete feeds and extracts valid data. This makes it suitable for use with real-world feeds that may not strictly follow specifications.
35
35
 
36
36
  ### Performance and Type-Safety
37
- * **Ultrafast parsing** ⚑ β€” One of the fastest JavaScript feed parsers ([see benchmarks](/benchmarks)).
38
- * **Type-safe API** πŸ›Ÿ β€” Built with TypeScript from the ground up, it provides complete type definitions for every feed format and namespace.
39
- * **Tree-shakable** πŸƒ β€” Only include the parts of the library you need, reducing bundle size.
40
- * **Well-tested** πŸ”¬ β€” Comprehensive test suite with over 2000 tests and 99% code coverage.
37
+ * **Ultrafast parsing** β€” One of the fastest JavaScript feed parsers ([see benchmarks](/benchmarks)).
38
+ * **Type-safe API** β€” Built with TypeScript from the ground up, it provides complete type definitions for every feed format and namespace.
39
+ * **Tree-shakable** β€” Only include the parts of the library you need, reducing bundle size.
40
+ * **Well-tested** β€” Comprehensive test suite with over 2000 tests and 99% code coverage.
41
41
 
42
42
  ### Compatibility
43
43
  * Works in Node.js 14.0.0+ and modern browsers.
@@ -56,23 +56,23 @@ Feedsmith aims to fully support all major feed formats and namespaces in complet
56
56
 
57
57
  ### Feeds
58
58
 
59
- | Format | Versions | Parsing | Generating |
60
- |--------|----------|---------|------------|
61
- | [RSS](http://cyber.law.harvard.edu/rss/rss.html) | 0.9x, 2.0 | βœ… | βœ… |
62
- | [Atom](https://tools.ietf.org/html/rfc4287) | 0.3, 1.0 | βœ… | βœ… |
63
- | [RDF](https://web.resource.org/rss/1.0/spec) | 0.9, 1.0 | βœ… | πŸ“‹ |
64
- | [JSON Feed](https://jsonfeed.org) | 1.0, 1.1 | βœ… | βœ… |
59
+ | Format | Versions | Parse | Generate |
60
+ |--------|----------|-------|----------|
61
+ | [RSS](https://feedsmith.dev/reference/feeds/rss) | 0.9x, 2.0 | βœ… | βœ… |
62
+ | [Atom](https://feedsmith.dev/reference/feeds/atom) | 0.3, 1.0 | βœ… | βœ… |
63
+ | [RDF](https://feedsmith.dev/reference/feeds/rdf) | 0.9, 1.0 | βœ… | πŸ“‹ |
64
+ | [JSON Feed](https://feedsmith.dev/reference/feeds/json) | 1.0, 1.1 | βœ… | βœ… |
65
65
 
66
66
  ### Other
67
67
 
68
- | Format | Versions | Parsing | Generating |
69
- |--------|----------|---------|------------|
70
- | [OPML](https://opml.org/) | 1.0, 2.0 | βœ… | βœ… |
68
+ | Format | Versions | Parse | Generate |
69
+ |--------|----------|-------|----------|
70
+ | [OPML](https://feedsmith.dev/reference/other/opml) | 1.0, 2.0 | βœ… | βœ… |
71
71
 
72
72
  ### Feed Namespaces
73
73
 
74
- | Name | Prefix | Supported in | Parsing | Generating |
75
- |------|---------|--------------|---------|------------|
74
+ | Name | Prefix | Supported in | Parse | Generate |
75
+ |------|---------|--------------|-------|----------|
76
76
  | [Atom](https://feedsmith.dev/reference/namespaces/atom) | `<atom:*>` | RSS, RDF | βœ… | βœ… |
77
77
  | [Dublin Core](https://feedsmith.dev/reference/namespaces/dc) | `<dc:*>` | RSS, Atom, RDF | βœ… | βœ… |
78
78
  | [Dublin Core Terms](https://feedsmith.dev/reference/namespaces/dcterms) | `<dcterms:*>` | RSS, Atom, RDF | βœ… | βœ… |
@@ -64,39 +64,32 @@ const generateSingularOrArray = (singularValue, pluralValues, generator) => {
64
64
  };
65
65
  const cdataStartTag = "<![CDATA[";
66
66
  const cdataEndTag = "]]>";
67
- const stripCdata = (text) => {
68
- if (typeof text !== "string") return text;
67
+ const hasEntities = (text) => {
68
+ const ampIndex = text.indexOf("&");
69
+ return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
70
+ };
71
+ const decodeWithCdata = (text) => {
69
72
  let currentIndex = text.indexOf(cdataStartTag);
70
- if (currentIndex === -1) return text;
73
+ if (currentIndex === -1) return hasEntities(text) ? (0, entities.decodeHTML)(text) : text;
71
74
  let result = "";
72
75
  let lastIndex = 0;
73
76
  while (currentIndex !== -1) {
74
- result += text.substring(lastIndex, currentIndex);
75
- lastIndex = text.indexOf(cdataEndTag, currentIndex + 9);
76
- if (lastIndex === -1) return text;
77
- result += text.substring(currentIndex + 9, lastIndex);
78
- lastIndex += 3;
77
+ const textBefore = text.substring(lastIndex, currentIndex);
78
+ result += hasEntities(textBefore) ? (0, entities.decodeHTML)(textBefore) : textBefore;
79
+ const endIndex = text.indexOf(cdataEndTag, currentIndex + 9);
80
+ if (endIndex === -1) return hasEntities(text) ? (0, entities.decodeHTML)(text) : text;
81
+ result += text.substring(currentIndex + 9, endIndex);
82
+ lastIndex = endIndex + 3;
79
83
  currentIndex = text.indexOf(cdataStartTag, lastIndex);
80
84
  }
81
- result += text.substring(lastIndex);
85
+ const textAfter = text.substring(lastIndex);
86
+ result += hasEntities(textAfter) ? (0, entities.decodeHTML)(textAfter) : textAfter;
82
87
  return result;
83
88
  };
84
- const hasEntities = (text) => {
85
- const ampIndex = text.indexOf("&");
86
- return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
87
- };
88
89
  const parseString = (value) => {
89
90
  if (typeof value === "string") {
90
91
  if (value === "") return;
91
- let string = value;
92
- if (value.indexOf(cdataStartTag) !== -1) string = stripCdata(value);
93
- string = string.trim();
94
- if (string === "") return;
95
- if (hasEntities(string)) {
96
- string = (0, entities.decodeXML)(string);
97
- if (hasEntities(string)) string = (0, entities.decodeHTML)(string);
98
- }
99
- return string || void 0;
92
+ return decodeWithCdata(value).trim() || void 0;
100
93
  }
101
94
  if (typeof value === "number") return value.toString();
102
95
  };
@@ -1,4 +1,4 @@
1
- import { decodeHTML, decodeXML } from "entities";
1
+ import { decodeHTML } from "entities";
2
2
 
3
3
  //#region src/common/utils.ts
4
4
  const isPresent = (value) => {
@@ -64,39 +64,32 @@ const generateSingularOrArray = (singularValue, pluralValues, generator) => {
64
64
  };
65
65
  const cdataStartTag = "<![CDATA[";
66
66
  const cdataEndTag = "]]>";
67
- const stripCdata = (text) => {
68
- if (typeof text !== "string") return text;
67
+ const hasEntities = (text) => {
68
+ const ampIndex = text.indexOf("&");
69
+ return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
70
+ };
71
+ const decodeWithCdata = (text) => {
69
72
  let currentIndex = text.indexOf(cdataStartTag);
70
- if (currentIndex === -1) return text;
73
+ if (currentIndex === -1) return hasEntities(text) ? decodeHTML(text) : text;
71
74
  let result = "";
72
75
  let lastIndex = 0;
73
76
  while (currentIndex !== -1) {
74
- result += text.substring(lastIndex, currentIndex);
75
- lastIndex = text.indexOf(cdataEndTag, currentIndex + 9);
76
- if (lastIndex === -1) return text;
77
- result += text.substring(currentIndex + 9, lastIndex);
78
- lastIndex += 3;
77
+ const textBefore = text.substring(lastIndex, currentIndex);
78
+ result += hasEntities(textBefore) ? decodeHTML(textBefore) : textBefore;
79
+ const endIndex = text.indexOf(cdataEndTag, currentIndex + 9);
80
+ if (endIndex === -1) return hasEntities(text) ? decodeHTML(text) : text;
81
+ result += text.substring(currentIndex + 9, endIndex);
82
+ lastIndex = endIndex + 3;
79
83
  currentIndex = text.indexOf(cdataStartTag, lastIndex);
80
84
  }
81
- result += text.substring(lastIndex);
85
+ const textAfter = text.substring(lastIndex);
86
+ result += hasEntities(textAfter) ? decodeHTML(textAfter) : textAfter;
82
87
  return result;
83
88
  };
84
- const hasEntities = (text) => {
85
- const ampIndex = text.indexOf("&");
86
- return ampIndex !== -1 && text.indexOf(";", ampIndex) !== -1;
87
- };
88
89
  const parseString = (value) => {
89
90
  if (typeof value === "string") {
90
91
  if (value === "") return;
91
- let string = value;
92
- if (value.indexOf(cdataStartTag) !== -1) string = stripCdata(value);
93
- string = string.trim();
94
- if (string === "") return;
95
- if (hasEntities(string)) {
96
- string = decodeXML(string);
97
- if (hasEntities(string)) string = decodeHTML(string);
98
- }
99
- return string || void 0;
92
+ return decodeWithCdata(value).trim() || void 0;
100
93
  }
101
94
  if (typeof value === "number") return value.toString();
102
95
  };
package/package.json CHANGED
@@ -73,14 +73,14 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "entities": "^7.0.0",
76
- "fast-xml-parser": "^5.3.2"
76
+ "fast-xml-parser": "^5.3.3"
77
77
  },
78
78
  "devDependencies": {
79
- "@types/bun": "^1.3.3",
80
- "kvalita": "^1.5.0",
81
- "tsdown": "^0.16.8",
79
+ "@types/bun": "^1.3.4",
80
+ "kvalita": "^1.8.0",
81
+ "tsdown": "^0.17.3",
82
82
  "vitepress": "^1.6.4",
83
83
  "vitepress-plugin-llms": "^1.9.3"
84
84
  },
85
- "version": "2.7.0"
85
+ "version": "2.8.0"
86
86
  }