@rmdes/indiekit-endpoint-podroll 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/lib/sync.js +16 -1
  2. package/package.json +1 -1
package/lib/sync.js CHANGED
@@ -106,6 +106,21 @@ async function fetchOpmlSources(url, timeout) {
106
106
  }
107
107
  }
108
108
 
109
+ /**
110
+ * Decode HTML entities in URLs (FreshRSS returns XML-encoded URLs)
111
+ * @param {string} str
112
+ * @returns {string}
113
+ */
114
+ function decodeHtmlEntities(str) {
115
+ if (!str) return str;
116
+ return str
117
+ .replace(/&/g, "&")
118
+ .replace(/&lt;/g, "<")
119
+ .replace(/&gt;/g, ">")
120
+ .replace(/&quot;/g, '"')
121
+ .replace(/&#39;/g, "'");
122
+ }
123
+
109
124
  /**
110
125
  * Transform FreshRSS episode to our schema
111
126
  * @param {object} item - FreshRSS item
@@ -117,7 +132,7 @@ function transformEpisode(item) {
117
132
  if (item.enclosure && item.enclosure.length > 0) {
118
133
  const enc = item.enclosure[0];
119
134
  enclosure = {
120
- url: enc.href || enc.url,
135
+ url: decodeHtmlEntities(enc.href || enc.url),
121
136
  type: enc.type || "audio/mpeg",
122
137
  length: enc.length ? parseInt(enc.length, 10) : 0,
123
138
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-podroll",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Podcast roll endpoint for Indiekit. Aggregates podcast episodes from FreshRSS, displays on frontend with OPML sidebar.",
5
5
  "keywords": [
6
6
  "indiekit",