mailcomposer
Advanced tools
Comparing version 0.2.11 to 0.2.12
@@ -419,2 +419,30 @@ "use strict"; | ||
MailComposer.prototype.convertAddress = function(address) { | ||
// if user part of the address contains foreign symbols | ||
// make a mime word of it | ||
address.address = address.address.replace(/^.*?(?=\@)/, (function(user) { | ||
if (this._hasUTFChars(user)) { | ||
return mimelib.encodeMimeWord(user, "Q", this.options.charset); | ||
} else { | ||
return user; | ||
} | ||
}).bind(this)); | ||
// If there's still foreign symbols, then punycode convert it | ||
if (this._hasUTFChars(address.address)) { | ||
address.address = toPunycode(address.address); | ||
} | ||
if (!address.name) { | ||
return address.address; | ||
} else if (address.name) { | ||
if (this._hasUTFChars(address.name)) { | ||
address.name = this._encodePartialMimeWord(address.name, "Q", 52); | ||
} else { | ||
address.name = JSON.stringify(address.name); | ||
} | ||
return address.name + ' <' + address.address + '>'; | ||
} | ||
}; | ||
/* PRIVATE API */ | ||
@@ -534,3 +562,3 @@ | ||
if (address.address) { | ||
values.push(this._convertAddress(address)); | ||
values.push(this.convertAddress(address)); | ||
} | ||
@@ -544,3 +572,3 @@ if (address.group) { | ||
} | ||
values.push(address.name + ":" + address.group.map(this._convertAddress.bind(this)).join(", ") + ";"); | ||
values.push(address.name + ":" + address.group.map(this.convertAddress.bind(this)).join(", ") + ";"); | ||
} | ||
@@ -552,30 +580,2 @@ | ||
MailComposer.prototype._convertAddress = function(address) { | ||
// if user part of the address contains foreign symbols | ||
// make a mime word of it | ||
address.address = address.address.replace(/^.*?(?=\@)/, (function(user) { | ||
if (this._hasUTFChars(user)) { | ||
return mimelib.encodeMimeWord(user, "Q", this.options.charset); | ||
} else { | ||
return user; | ||
} | ||
}).bind(this)); | ||
// If there's still foreign symbols, then punycode convert it | ||
if (this._hasUTFChars(address.address)) { | ||
address.address = toPunycode(address.address); | ||
} | ||
if (!address.name) { | ||
return address.address; | ||
} else if (address.name) { | ||
if (this._hasUTFChars(address.name)) { | ||
address.name = this._encodePartialMimeWord(address.name, "Q", 52); | ||
} else { | ||
address.name = JSON.stringify(address.name); | ||
} | ||
return address.name + ' <' + address.address + '>'; | ||
} | ||
}; | ||
/** | ||
@@ -582,0 +582,0 @@ * <p>Gets a header field</p> |
@@ -7,5 +7,4 @@ "use strict"; | ||
return address.replace(/((?:https?:\/\/)?.*\@)?([^\/]*)/, function(o, start, domain) { | ||
var domainParts = domain.split(/\./).map(punycode.toASCII.bind(punycode)); | ||
return (start || "") + domainParts.join("."); | ||
return (start || "") + punycode.toASCII(domain); | ||
}); | ||
}; |
{ | ||
"name": "mailcomposer", | ||
"description": "Compose E-Mail messages", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"author": "Andris Reinman", | ||
@@ -30,3 +30,2 @@ "maintainers": [ | ||
"he": "~0.3.6", | ||
"punycode": "~1.2.4", | ||
"follow-redirects": "0.0.3", | ||
@@ -40,3 +39,3 @@ "dkim-signer": "~0.1.1" | ||
"engine": { | ||
"node": ">=0.4" | ||
"node": ">=0.8" | ||
}, | ||
@@ -43,0 +42,0 @@ "keywords": [ |
@@ -209,2 +209,12 @@ # mailcomposer | ||
Addresses can be encoded using `mailcomposer.convertAddress(options)` | ||
```javascript | ||
var address = mailcomposer.convertAddress({ | ||
name: 'username@example.com', | ||
address: 'Ноде Майлер' | ||
}); | ||
// "Ноде Майлер" <username@example.com> | ||
``` | ||
### SMTP envelope | ||
@@ -211,0 +221,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68004
5
426
1402
- Removedpunycode@~1.2.4