diff --git a/src/__tests__/__snapshots__/atom1.spec.ts.snap b/src/__tests__/__snapshots__/atom1.spec.ts.snap index 5fd101e..569cf1d 100644 --- a/src/__tests__/__snapshots__/atom1.spec.ts.snap +++ b/src/__tests__/__snapshots__/atom1.spec.ts.snap @@ -42,6 +42,9 @@ exports[`atom 1.0 should generate a valid feed 1`] = ` joesmith@example.com https://example.com/joesmith + + Joe Smith, Name Only + diff --git a/src/__tests__/setup.ts b/src/__tests__/setup.ts index 28523f1..79d77f7 100644 --- a/src/__tests__/setup.ts +++ b/src/__tests__/setup.ts @@ -45,13 +45,16 @@ sampleFeed.addItem({ { name: "Jane Doe", email: "janedoe@example.com", - link: "https://example.com/janedoe?link=sanitized&value=2" + link: "https://example.com/janedoe?link=sanitized&value=2", }, { name: "Joe Smith", email: "joesmith@example.com", link: "https://example.com/joesmith", }, + { + name: "Joe Smith, Name Only", + } ], contributor: [ { diff --git a/src/atom1.ts b/src/atom1.ts index 56f686d..3bfe29b 100644 --- a/src/atom1.ts +++ b/src/atom1.ts @@ -167,21 +167,26 @@ export default (ins: Feed) => { }; /** - * Returns a formated author + * Returns a formatted author * @param author */ const formatAuthor = (author: Author) => { const { name, email, link } = author; - return { - name, - email, - uri: sanitize(link) - }; + const out: { name?: string, email?: string, uri?: string } = { name }; + if (email) { + out.email = email; + } + + if (link) { + out.uri = sanitize(link); + } + + return out; }; /** - * Returns a formated category + * Returns a formatted category * @param category */ const formatCategory = (category: Category) => { diff --git a/src/utils.ts b/src/utils.ts index fe31200..2e553d3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -export function sanitize(url: String | undefined): String | undefined { +export function sanitize(url: string | undefined): string | undefined { if (typeof (url) === 'undefined') { return; }