Skip to content

Commit

Permalink
fix: correctly text.trim() in parseSpecCompliantText (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg authored Aug 28, 2022
1 parent 25c534b commit b64a9d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class Mailbox {
}

parseSpecCompliantText(text) {
text.trim()
text = text.trim()

if (text.slice(0, 1) == '<' && text.slice(-1) == '>') {
return {addr: text.slice(1, -1)}
Expand Down
4 changes: 4 additions & 0 deletions tests/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ assert.strictEqual(msg1.getSender().name, 'Lorem Ipsum')
assert.strictEqual(msg1.getSender().addr, 'lorem@ipsum.com')
assert.strictEqual(msg1.getSender().type.toLowerCase(), 'from')

msg1.setSender(' Lorem Ipsum Trimmus <lorem@ipsum.trimmus.com> ')
assert.strictEqual(msg1.getSender().name, 'Lorem Ipsum Trimmus')
assert.strictEqual(msg1.getSender().addr, 'lorem@ipsum.trimmus.com')

msg1.setTo({name: 'Foo Bör', addr: 'foobor@test.com'})
assert.strictEqual(msg1.getRecipients({type: 'to'}).length > 0, true)
assert.strictEqual(msg1.getRecipients({type: 'to'})[0].name, 'Foo Bör')
Expand Down

0 comments on commit b64a9d3

Please sign in to comment.