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

"html": false #309

Open
joelterry opened this issue Jan 10, 2022 · 1 comment
Open

"html": false #309

joelterry opened this issue Jan 10, 2022 · 1 comment

Comments

@joelterry
Copy link

I have seen a parsed email object with the html field set to false, and have noticed a handful of issues that mention this. Here are a few examples:

#185
#187
#252

My issue isn't even about whether the parser correctly or incorrectly omitted the HTML, but rather the use of false as an empty/uninitialized string value, which the code seems to be doing: https://github.com/nodemailer/mailparser/blob/master/lib/mail-parser.js#L152.

Is there any reason why you're using false instead of null, undefined, or ""? People who see these false values will likely misunderstand the email object schema (as in .html indicates the presence of HTML rather than holds its content). Additionally, if this object is sent further down the wire, people will choose to encode/decode with the assumption that .html is a string, or maybe an optional string, but probably not a string|boolean.

That being said, that's just my gut feeling, let me know if I'm missing something. I also understand if this project has too much momentum to make such a change now.

@Ionys320
Copy link

Ionys320 commented Apr 4, 2023

I agree that using null or even undefined would probably be better, allowing for example to do mail.html ?? mail.textAsHtml (may already work in JavaScript, but not in TypeScript because of the type of the html property) instead of mail.html != false ? mail.html : mail.textAsHtml.

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

No branches or pull requests

2 participants