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 +23 -23
- package/dist/common/utils.cjs +15 -22
- package/dist/common/utils.js +16 -23
- package/package.json +5 -5
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**
|
|
26
|
-
* **Preserves structure**
|
|
27
|
-
* **Smart namespace handling**
|
|
28
|
-
* **Parsing & generating**
|
|
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**
|
|
32
|
-
* **CaSe INSENsiTive**
|
|
33
|
-
* **Namespace URI tolerance**
|
|
34
|
-
* **Forgiving**
|
|
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**
|
|
38
|
-
* **Type-safe API**
|
|
39
|
-
* **Tree-shakable**
|
|
40
|
-
* **Well-tested**
|
|
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 |
|
|
60
|
-
|
|
61
|
-
| [RSS](
|
|
62
|
-
| [Atom](https://
|
|
63
|
-
| [RDF](https://
|
|
64
|
-
| [JSON Feed](https://
|
|
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 |
|
|
69
|
-
|
|
70
|
-
| [OPML](https://
|
|
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 |
|
|
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 | β
| β
|
|
package/dist/common/utils.cjs
CHANGED
|
@@ -64,39 +64,32 @@ const generateSingularOrArray = (singularValue, pluralValues, generator) => {
|
|
|
64
64
|
};
|
|
65
65
|
const cdataStartTag = "<![CDATA[";
|
|
66
66
|
const cdataEndTag = "]]>";
|
|
67
|
-
const
|
|
68
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
};
|
package/dist/common/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeHTML
|
|
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
|
|
68
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
76
|
+
"fast-xml-parser": "^5.3.3"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@types/bun": "^1.3.
|
|
80
|
-
"kvalita": "^1.
|
|
81
|
-
"tsdown": "^0.
|
|
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.
|
|
85
|
+
"version": "2.8.0"
|
|
86
86
|
}
|