File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -70,13 +70,13 @@ function map(array, callback) {
7070 * function.
7171 */
7272function mapDomain ( domain , callback ) {
73- const parts = domain . split ( '@' ) ;
73+ const atPos = domain . 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- domain = parts [ 1 ] ;
78+ result = domain . substring ( 0 , atPos + 1 ) ;
79+ domain = domain . substring ( atPos + 1 ) ;
8080 }
8181 // Avoid `split(regex)` for IE8 compatibility. See #17.
8282 domain = domain . replace ( regexSeparators , '\x2E' ) ;
Original file line number Diff line number Diff line change @@ -216,6 +216,11 @@ const testData = {
216216 { // https://github.com/mathiasbynens/punycode.js/pull/115
217217 'decoded' : 'foo\x7F.example' ,
218218 'encoded' : 'foo\x7F.example'
219+ } ,
220+ {
221+ "description" : "Email address that includes multiple at signs" ,
222+ "decoded" : "\"very.(),:;<>[]\\\".VERY.\\\"@very@\\ \\\"very\\\".unusual\"@\uD83D\uDCA9.la" ,
223+ "encoded" : "\"very.(),:;<>[]\\\".VERY.\\\"@very@\\ \\\"very\\\".unusual\"@xn--ls8h.la"
219224 }
220225 ] ,
221226 'separators' : [
You can’t perform that action at this time.
0 commit comments