Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(edition) : Cannot read property 'year' of undefined #344

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/routes/entity/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function transformNewForm(data) {
);

let releaseEvents = [];
if (data.editionSection.releaseDate.year) {
if (data.editionSection.releaseDate && data.editionSection.releaseDate.year) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would've worked also if(data.edition.releaseData){.. because year is an empty string by default and will always be present.
But I think it's better to be safe :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I think also if by any chance you get something other than a {year,month,day} object (like a date string), calling dateObjectToISOString with it will throw an error.

releaseEvents = [{date: dateObjectToISOString(data.editionSection.releaseDate)}];
}

Expand Down