Skip to content

Commit

Permalink
Merge 7bfd4ec into 50ed093
Browse files Browse the repository at this point in the history
  • Loading branch information
Decebal Dobrica committed Jun 6, 2020
2 parents 50ed093 + 7bfd4ec commit 1237e99
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/__snapshots__/atom1.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ exports[`atom 1.0 should generate a valid feed 1`] = `
<email>joesmith@example.com</email>
<uri>https://example.com/joesmith</uri>
</author>
<author>
<name>Joe Smith, Name Only</name>
</author>
<category label=\\"Grateful Dead\\"/>
<category label=\\"MSFT\\"/>
<contributor>
Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
link: "https://example.com/joesmith"
},
{
name: "Joe Smith, Name Only",
}
],
contributor: [
{
Expand Down
19 changes: 12 additions & 7 deletions src/atom1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down

0 comments on commit 1237e99

Please sign in to comment.