feed-slurp 1.0.0 → 1.0.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/index.js +16 -5
- package/dist/index.mjs +16 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -109,12 +109,23 @@ function parseRss(doc) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
function extractThumbnail(item, content) {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
const mediaTags = ["media\\:content", "media\\:thumbnail", "content", "thumbnail"];
|
|
113
|
+
for (const tag of mediaTags) {
|
|
114
|
+
const el = item.querySelector(tag);
|
|
115
|
+
if (el) {
|
|
116
|
+
const url = el.getAttribute("url") || el.getAttribute("src");
|
|
117
|
+
if (url) return url;
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
120
|
+
const enclosure = item.querySelector("enclosure[type^='image']");
|
|
121
|
+
if (enclosure) {
|
|
122
|
+
const url = enclosure.getAttribute("url");
|
|
123
|
+
if (url) return url;
|
|
124
|
+
}
|
|
125
|
+
const imgRegex = /<img[^>]+src=["']([^"']+)["']/i;
|
|
126
|
+
const match = content.match(imgRegex);
|
|
127
|
+
if (match && match[1]) return match[1];
|
|
128
|
+
return null;
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
// src/parser/atom.ts
|
package/dist/index.mjs
CHANGED
|
@@ -81,12 +81,23 @@ function parseRss(doc) {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
function extractThumbnail(item, content) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
const mediaTags = ["media\\:content", "media\\:thumbnail", "content", "thumbnail"];
|
|
85
|
+
for (const tag of mediaTags) {
|
|
86
|
+
const el = item.querySelector(tag);
|
|
87
|
+
if (el) {
|
|
88
|
+
const url = el.getAttribute("url") || el.getAttribute("src");
|
|
89
|
+
if (url) return url;
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
92
|
+
const enclosure = item.querySelector("enclosure[type^='image']");
|
|
93
|
+
if (enclosure) {
|
|
94
|
+
const url = enclosure.getAttribute("url");
|
|
95
|
+
if (url) return url;
|
|
96
|
+
}
|
|
97
|
+
const imgRegex = /<img[^>]+src=["']([^"']+)["']/i;
|
|
98
|
+
const match = content.match(imgRegex);
|
|
99
|
+
if (match && match[1]) return match[1];
|
|
100
|
+
return null;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
// src/parser/atom.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feed-slurp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A lightweight, zero-dependency (well, almost!) RSS/Atom feed fetcher and parser with built-in caching and proxy support.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|