ReachFive / fake-smtp-server

Fake SMTP Server for email testing
https://www.npmjs.com/package/fake-smtp-server
MIT License
192 stars 81 forks source link

Headers aren't properly serialized to JSON #7

Closed bioball closed 6 years ago

bioball commented 6 years ago

Great module! However, I'm noticing that the headers aren't being properly serialized to JSON.

simpleParser turns the headers into a Map object, and when Map's are JSON-stringified, they get serialized as "{}", regardless of whether there's data in the map or not. There should be some extra logic that deals with how to serialize these.

This link should be helpful: http://2ality.com/2015/08/es6-map-json.html

jcdelmas commented 6 years ago

Thanks !

In fact, informations present in headers map are already available in the root object (from, to, date...). So I chose to delete it rather than parsing it.

I hope this is not a problem for you.

bioball commented 6 years ago

It is a problem unfortunately, as I'm sending custom mail headers, and am trying to write tests around them :(

I'd be happy to send a PR for this if you want.

jcdelmas commented 6 years ago

Oh sorry. Don't hesitate to make a PR. To avoid document overload, you can add an option to enable headers serialization only when necessary.

bioball commented 6 years ago

Done!

bioball commented 6 years ago

Thanks for merging the PR! Can you publish a new version of this module?

jcdelmas commented 6 years ago

Done !

bioball commented 6 years ago

Great, thanks!