diff --git a/src/formats/atom/atom.conformance.test.ts b/src/formats/atom/atom.conformance.test.ts
index 8fa439c..ef859cf 100644
--- a/src/formats/atom/atom.conformance.test.ts
+++ b/src/formats/atom/atom.conformance.test.ts
@@ -390,4 +390,24 @@ describe('Atom enclosure mapping (RFC 4287 §4.2.7.2)', () => {
)
expect(xml).not.toContain('1800')
})
+
+ it('ignores enclosure.title (JSON Feed-only attachment field, no Atom mapping)', () => {
+ const xml = toAtom({
+ ...withEnclosure,
+ items: [
+ {
+ ...withEnclosure.items[0],
+ enclosure: {
+ url: 'https://example.com/ep1.mp3',
+ type: 'audio/mpeg',
+ title: 'Episode 1',
+ },
+ },
+ ],
+ })
+ expect(xml).toContain(
+ '',
+ )
+ expect(xml).not.toContain('Episode 1')
+ })
})
diff --git a/src/formats/json/index.ts b/src/formats/json/index.ts
index 28c794a..6b206f0 100644
--- a/src/formats/json/index.ts
+++ b/src/formats/json/index.ts
@@ -106,6 +106,7 @@ function jsonItem(item: FeedItem, v1: boolean, base?: string): Record {
expect(json.items[0].attachments[0].duration_in_seconds).toBeUndefined()
})
+ it('maps enclosure.title to the attachment title', () => {
+ const json = JSON.parse(
+ toJSONFeed({
+ options: { title: 't', link: 'https://example.com/' },
+ items: [
+ {
+ title: 'a',
+ link: 'https://example.com/1',
+ content: 'b
',
+ enclosure: {
+ url: 'https://example.com/a.mp3',
+ type: 'audio/mpeg',
+ title: 'Episode 1',
+ },
+ },
+ ],
+ }),
+ )
+ expect(json.items[0].attachments[0].title).toBe('Episode 1')
+ })
+
+ it('omits the attachment title when the enclosure has no title', () => {
+ const json = JSON.parse(
+ toJSONFeed({
+ options: { title: 't', link: 'https://example.com/' },
+ items: [
+ {
+ title: 'a',
+ link: 'https://example.com/1',
+ content: 'b
',
+ enclosure: { url: 'https://example.com/a.mp3', type: 'audio/mpeg' },
+ },
+ ],
+ }),
+ )
+ expect(json.items[0].attachments[0].title).toBeUndefined()
+ })
+
it('pretty-prints with 2-space indentation', () => {
const out = toJSONFeed(
{ options: { title: 't', link: 'https://example.com/' }, items: [] },
diff --git a/src/types.ts b/src/types.ts
index 820e0f5..237e493 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -48,6 +48,8 @@ export interface Enclosure {
length?: number
/** Duration in seconds. JSON Feed `duration_in_seconds`; no RSS/Atom enclosure equivalent. */
duration?: number
+ /** Attachment name. JSON Feed `title`; Atom link `title`; no RSS equivalent. */
+ title?: string
}
/** `itunes:owner` — the podcast's admin contact, shown only to Apple Podcasts, never in the UI. */