Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

processAddress.js doesn't handle name as an object correctly #30

Open
ivangreene opened this issue Aug 1, 2017 · 3 comments
Open

processAddress.js doesn't handle name as an object correctly #30

ivangreene opened this issue Aug 1, 2017 · 3 comments
Labels
Milestone

Comments

@ivangreene
Copy link

In processAddress.js, there is a conditional to handle data.name being an object, and convert something like { first: 'My', last: 'Name' } into simply "My Name".
I've tested this with node 8.0.0 and 6.11.1 and neither behave as expected, still giving the stringified object in the "to" field of emails.

I added a few log statements to see what's going on, and it seems there is a failed attempt to modify the passed object (I've included line numbers in the snippet)

15>    data.name = [data.name.first, data.name.last].filter(truthy).join(' '); // Should be assigning data.name to a string?
16>    console.log(data.name); // output: { first: 'Admin', last: 'User' }
17>    console.log([data.name.first, data.name.last].filter(truthy).join(' ')); // output: Admin User

data is not successfully being modified here for some reason (anyone more familiar with JS object references care to explain?) (data is the sole argument of processAddress()).
I propose that instead of modifying the passed object reference, rtn.name is assigned directly. There are no other points where the data argument is (needlessly) modified in this function.

@kaaljabr
Copy link

kaaljabr commented Sep 7, 2018

Any updates on this?

@stennie
Copy link
Contributor

stennie commented Sep 10, 2018

@kaaljabr No specific update aside from the bug apparently still existing. It looks like @ivangreene's PR #31 will address this, but didn't get any feedback to progress. The code change should be accompanied by an updated test case, and the baseline for Node support is now LTS (currently Node 6 & 8) so failures in Node 0.12 are no longer relevant.

I'll resurrect and fix the PR.

Regards,
Stennie

@stennie stennie added this to the 1.1.1 milestone Sep 10, 2018
@kaaljabr
Copy link

kaaljabr commented Sep 10, 2018

Here is a workaround for it:

admins = admins.map(admin => {
 const {
	name: {
	             full: name,
	},
	email: email,
} = admin;
return { name: name, email: email };
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants