Skip to content

Commit

Permalink
Fixes #1524 - Type Error thrown by empty addressBook (#1525)
Browse files Browse the repository at this point in the history
* Fixes #1524
Error was caused by `fieldData.addressBook` existing as an empty array, this checks to make sure that `addressBook[0]` exists before looking for the `fullName` prop.

* fix camelcase typo that was breaking tests.

* Actually fix typo in addressBook.

Previous commit is what happens when you have two editor windows open with similar files open.
  • Loading branch information
Spencer Norman authored and Aaron Judd committed Oct 25, 2016
1 parent 7f8cfd2 commit 5a4fcb4
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ transformations.accounts.emails = function (fieldData) {

transformations.accounts.profile = function (fieldData) {
let profileObject;
if (fieldData && fieldData.addressBook && fieldData.addressBook[0].fullName) {
if (fieldData && fieldData.addressBook && fieldData.addressBook[0] && fieldData.addressBook[0].fullName) {
profileObject = {
firstName: _.split(fieldData.addressBook[0].fullName, " ")[0],
lastName: _.split(fieldData.addressBook[0].fullName, " ")[1],
Expand All @@ -37,4 +37,3 @@ transformations.accounts.profile = function (fieldData) {
}
return profileObject;
};

0 comments on commit 5a4fcb4

Please sign in to comment.