Skip to content

Commit ce2d389

Browse files
authored
Sanitize url when formatting enclosure (#193)
1 parent 21882ed commit ce2d389

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rss2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ export default (ins: Feed) => {
264264
*/
265265
const formatEnclosure = (enclosure: string | Enclosure, mimeCategory = "image") => {
266266
if (typeof enclosure === "string") {
267-
const type = new URL(enclosure).pathname.split(".").slice(-1)[0];
267+
const type = new URL(sanitize(enclosure)).pathname.split(".").slice(-1)[0];
268268
return { _attributes: { url: enclosure, length: 0, type: `${mimeCategory}/${type}` } };
269269
}
270270

271-
const type = new URL(enclosure.url).pathname.split(".").slice(-1)[0];
271+
const type = new URL(sanitize(enclosure.url)).pathname.split(".").slice(-1)[0];
272272
return { _attributes: { length: 0, type: `${mimeCategory}/${type}`, ...enclosure } };
273273
};
274274

0 commit comments

Comments
 (0)