Skip to content

Commit ba41784

Browse files
committed
email address parsing correction
1 parent 98fb2ca commit ba41784

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

punycode.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ function map(array, fn) {
7070
* function.
7171
*/
7272
function mapDomain(string, fn) {
73-
const parts = string.split('@');
73+
const atPos = string.lastIndexOf('@');
7474
let result = '';
75-
if (parts.length > 1) {
75+
if (atPos > -1) {
7676
// In email addresses, only the domain name should be punycoded. Leave
7777
// the local part (i.e. everything up to `@`) intact.
78-
result = parts[0] + '@';
79-
string = parts[1];
78+
result = string.substring(0, atPos + 1);
79+
string = string.substring(atPos + 1);
8080
}
8181
// Avoid `split(regex)` for IE8 compatibility. See #17.
8282
string = string.replace(regexSeparators, '\x2E');

0 commit comments

Comments
 (0)