feedsmith 2.4.0 → 2.4.1
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/common/utils.cjs +4 -3
- package/dist/common/utils.js +4 -3
- package/dist/feeds/atom/detect/index.cjs +1 -1
- package/dist/feeds/atom/detect/index.js +1 -1
- package/dist/feeds/atom/parse/utils.cjs +2 -1
- package/dist/feeds/atom/parse/utils.js +2 -1
- package/dist/feeds/rdf/detect/index.cjs +1 -1
- package/dist/feeds/rdf/detect/index.js +1 -1
- package/dist/feeds/rss/detect/index.cjs +1 -1
- package/dist/feeds/rss/detect/index.js +1 -1
- package/package.json +3 -3
package/dist/common/utils.cjs
CHANGED
|
@@ -222,7 +222,7 @@ const detectNamespaces = (value, recursive = false) => {
|
|
|
222
222
|
if (isObject(current)) for (const key in current) {
|
|
223
223
|
if (seenKeys.has(key)) continue;
|
|
224
224
|
seenKeys.add(key);
|
|
225
|
-
const keyWithoutAt = key.
|
|
225
|
+
const keyWithoutAt = key.charCodeAt(0) === 64 ? key.slice(1) : key;
|
|
226
226
|
const colonIndex = keyWithoutAt.indexOf(":");
|
|
227
227
|
if (colonIndex > 0) namespaces.add(keyWithoutAt.slice(0, colonIndex));
|
|
228
228
|
if (recursive) traverse(current[key]);
|
|
@@ -231,9 +231,10 @@ const detectNamespaces = (value, recursive = false) => {
|
|
|
231
231
|
traverse(value);
|
|
232
232
|
return namespaces;
|
|
233
233
|
};
|
|
234
|
+
const cdataSpecialCharsRegex = /[<>&]|]]>/;
|
|
234
235
|
const generateCdataString = (value) => {
|
|
235
236
|
if (!isNonEmptyString(value)) return;
|
|
236
|
-
if (
|
|
237
|
+
if (cdataSpecialCharsRegex.test(value)) return { "#cdata": value.trim() };
|
|
237
238
|
return value.trim();
|
|
238
239
|
};
|
|
239
240
|
const generateTextOrCdataString = (value) => {
|
|
@@ -300,7 +301,7 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
|
|
|
300
301
|
return name;
|
|
301
302
|
};
|
|
302
303
|
const normalizeKey = (key, context) => {
|
|
303
|
-
if (key.
|
|
304
|
+
if (key.charCodeAt(0) === 64) return `@${normalizeWithContext(key.substring(1), context, false)}`;
|
|
304
305
|
return normalizeWithContext(key, context, true);
|
|
305
306
|
};
|
|
306
307
|
const traverseAndNormalize = (object, parentContext = {}) => {
|
package/dist/common/utils.js
CHANGED
|
@@ -220,7 +220,7 @@ const detectNamespaces = (value, recursive = false) => {
|
|
|
220
220
|
if (isObject(current)) for (const key in current) {
|
|
221
221
|
if (seenKeys.has(key)) continue;
|
|
222
222
|
seenKeys.add(key);
|
|
223
|
-
const keyWithoutAt = key.
|
|
223
|
+
const keyWithoutAt = key.charCodeAt(0) === 64 ? key.slice(1) : key;
|
|
224
224
|
const colonIndex = keyWithoutAt.indexOf(":");
|
|
225
225
|
if (colonIndex > 0) namespaces.add(keyWithoutAt.slice(0, colonIndex));
|
|
226
226
|
if (recursive) traverse(current[key]);
|
|
@@ -229,9 +229,10 @@ const detectNamespaces = (value, recursive = false) => {
|
|
|
229
229
|
traverse(value);
|
|
230
230
|
return namespaces;
|
|
231
231
|
};
|
|
232
|
+
const cdataSpecialCharsRegex = /[<>&]|]]>/;
|
|
232
233
|
const generateCdataString = (value) => {
|
|
233
234
|
if (!isNonEmptyString(value)) return;
|
|
234
|
-
if (
|
|
235
|
+
if (cdataSpecialCharsRegex.test(value)) return { "#cdata": value.trim() };
|
|
235
236
|
return value.trim();
|
|
236
237
|
};
|
|
237
238
|
const generateTextOrCdataString = (value) => {
|
|
@@ -298,7 +299,7 @@ const createNamespaceNormalizator = (namespaceUris, namespacePrefixes, primaryNa
|
|
|
298
299
|
return name;
|
|
299
300
|
};
|
|
300
301
|
const normalizeKey = (key, context) => {
|
|
301
|
-
if (key.
|
|
302
|
+
if (key.charCodeAt(0) === 64) return `@${normalizeWithContext(key.substring(1), context, false)}`;
|
|
302
303
|
return normalizeWithContext(key, context, true);
|
|
303
304
|
};
|
|
304
305
|
const traverseAndNormalize = (object, parentContext = {}) => {
|
|
@@ -3,7 +3,7 @@ const require_utils = require('../../../common/utils.cjs');
|
|
|
3
3
|
//#region src/feeds/atom/detect/index.ts
|
|
4
4
|
const detect = (value) => {
|
|
5
5
|
if (!require_utils.isNonEmptyString(value)) return false;
|
|
6
|
-
if (!/(
|
|
6
|
+
if (!/(?:^|[\s>])<(?:\w+:)?feed[\s>]/im.test(value)) return false;
|
|
7
7
|
const hasAtomNamespace = value.includes("http://www.w3.org/2005/Atom");
|
|
8
8
|
const hasAtomElements = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i.test(value);
|
|
9
9
|
return hasAtomNamespace || hasAtomElements;
|
|
@@ -3,7 +3,7 @@ import { isNonEmptyString } from "../../../common/utils.js";
|
|
|
3
3
|
//#region src/feeds/atom/detect/index.ts
|
|
4
4
|
const detect = (value) => {
|
|
5
5
|
if (!isNonEmptyString(value)) return false;
|
|
6
|
-
if (!/(
|
|
6
|
+
if (!/(?:^|[\s>])<(?:\w+:)?feed[\s>]/im.test(value)) return false;
|
|
7
7
|
const hasAtomNamespace = value.includes("http://www.w3.org/2005/Atom");
|
|
8
8
|
const hasAtomElements = /(<(?:\w+:)?(entry|title|link|id|updated|summary)[\s>])/i.test(value);
|
|
9
9
|
return hasAtomNamespace || hasAtomElements;
|
|
@@ -36,6 +36,7 @@ const createNamespaceGetter = (value, prefix) => {
|
|
|
36
36
|
};
|
|
37
37
|
const parseLink = (value) => {
|
|
38
38
|
if (!require_utils.isObject(value)) return;
|
|
39
|
+
const namespaces = require_utils.detectNamespaces(value);
|
|
39
40
|
return require_utils.trimObject({
|
|
40
41
|
href: require_utils.parseString(value["@href"]),
|
|
41
42
|
rel: require_utils.parseString(value["@rel"]),
|
|
@@ -43,7 +44,7 @@ const parseLink = (value) => {
|
|
|
43
44
|
hreflang: require_utils.parseString(value["@hreflang"]),
|
|
44
45
|
title: require_utils.parseString(value["@title"]),
|
|
45
46
|
length: require_utils.parseNumber(value["@length"]),
|
|
46
|
-
thr: require_utils$18.retrieveLink(value)
|
|
47
|
+
thr: namespaces.has("thr") ? require_utils$18.retrieveLink(value) : void 0
|
|
47
48
|
});
|
|
48
49
|
};
|
|
49
50
|
const retrievePersonUri = (value, options) => {
|
|
@@ -36,6 +36,7 @@ const createNamespaceGetter = (value, prefix) => {
|
|
|
36
36
|
};
|
|
37
37
|
const parseLink = (value) => {
|
|
38
38
|
if (!isObject(value)) return;
|
|
39
|
+
const namespaces = detectNamespaces(value);
|
|
39
40
|
return trimObject({
|
|
40
41
|
href: parseString(value["@href"]),
|
|
41
42
|
rel: parseString(value["@rel"]),
|
|
@@ -43,7 +44,7 @@ const parseLink = (value) => {
|
|
|
43
44
|
hreflang: parseString(value["@hreflang"]),
|
|
44
45
|
title: parseString(value["@title"]),
|
|
45
46
|
length: parseNumber(value["@length"]),
|
|
46
|
-
thr: retrieveLink(value)
|
|
47
|
+
thr: namespaces.has("thr") ? retrieveLink(value) : void 0
|
|
47
48
|
});
|
|
48
49
|
};
|
|
49
50
|
const retrievePersonUri = (value, options) => {
|
|
@@ -3,7 +3,7 @@ const require_utils = require('../../../common/utils.cjs');
|
|
|
3
3
|
//#region src/feeds/rdf/detect/index.ts
|
|
4
4
|
const detect = (value) => {
|
|
5
5
|
if (!require_utils.isNonEmptyString(value)) return false;
|
|
6
|
-
if (!/(
|
|
6
|
+
if (!/(?:^|[\s>])<(?:\w+:)?rdf[\s>]/im.test(value)) return false;
|
|
7
7
|
const hasRdfNamespace = value.includes("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
8
8
|
const hasRssNamespace = value.includes("http://purl.org/rss/1.0/");
|
|
9
9
|
const hasRdfElements = /(<(?:\w+:)?(channel|item|title|link|description)[\s>])/i.test(value);
|
|
@@ -3,7 +3,7 @@ import { isNonEmptyString } from "../../../common/utils.js";
|
|
|
3
3
|
//#region src/feeds/rdf/detect/index.ts
|
|
4
4
|
const detect = (value) => {
|
|
5
5
|
if (!isNonEmptyString(value)) return false;
|
|
6
|
-
if (!/(
|
|
6
|
+
if (!/(?:^|[\s>])<(?:\w+:)?rdf[\s>]/im.test(value)) return false;
|
|
7
7
|
const hasRdfNamespace = value.includes("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
8
8
|
const hasRssNamespace = value.includes("http://purl.org/rss/1.0/");
|
|
9
9
|
const hasRdfElements = /(<(?:\w+:)?(channel|item|title|link|description)[\s>])/i.test(value);
|
|
@@ -3,7 +3,7 @@ const require_utils = require('../../../common/utils.cjs');
|
|
|
3
3
|
//#region src/feeds/rss/detect/index.ts
|
|
4
4
|
const detect = (value) => {
|
|
5
5
|
if (!require_utils.isNonEmptyString(value)) return false;
|
|
6
|
-
if (!/(
|
|
6
|
+
if (!/(?:^|[\s>])<(?:\w+:)?rss[\s>]/im.test(value)) return false;
|
|
7
7
|
const hasVersionAttribute = /version\s*=\s*["'][^"']*["']/i.test(value);
|
|
8
8
|
const hasRssElements = /(<(channel|item|title|link|description|pubDate|guid)[\s>])/i.test(value);
|
|
9
9
|
return hasVersionAttribute || hasRssElements;
|
|
@@ -3,7 +3,7 @@ import { isNonEmptyString } from "../../../common/utils.js";
|
|
|
3
3
|
//#region src/feeds/rss/detect/index.ts
|
|
4
4
|
const detect = (value) => {
|
|
5
5
|
if (!isNonEmptyString(value)) return false;
|
|
6
|
-
if (!/(
|
|
6
|
+
if (!/(?:^|[\s>])<(?:\w+:)?rss[\s>]/im.test(value)) return false;
|
|
7
7
|
const hasVersionAttribute = /version\s*=\s*["'][^"']*["']/i.test(value);
|
|
8
8
|
const hasRssElements = /(<(channel|item|title|link|description|pubDate|guid)[\s>])/i.test(value);
|
|
9
9
|
return hasVersionAttribute || hasRssElements;
|
package/package.json
CHANGED
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"fast-xml-parser": "^5.3.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@types/bun": "^1.3.
|
|
79
|
+
"@types/bun": "^1.3.2",
|
|
80
80
|
"kvalita": "^1.3.1",
|
|
81
81
|
"tsdown": "^0.15.12",
|
|
82
82
|
"vitepress": "^1.6.4",
|
|
83
|
-
"vitepress-plugin-llms": "^1.
|
|
83
|
+
"vitepress-plugin-llms": "^1.9.1"
|
|
84
84
|
},
|
|
85
|
-
"version": "2.4.
|
|
85
|
+
"version": "2.4.1"
|
|
86
86
|
}
|