Skip to content

Commit 8368389

Browse files
committed
url: fix surrogate handling in encodeAuth()
1 parent 4cafa60 commit 8368389

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/internal/url.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ function encodeAuth(str) {
577577
}
578578
// Surrogate pair
579579
++i;
580+
++lastPos;
580581
var c2;
581582
if (i < str.length)
582583
c2 = str.charCodeAt(i) & 0x3FF;

test/parallel/test-url-format.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ const formatTests = {
235235
protocol: 'file',
236236
pathname: '/home/user',
237237
path: '/home/user'
238+
},
239+
240+
// surrogate in auth
241+
'http://%F0%9F%98%80@www.example.com/': {
242+
href: 'http://%F0%9F%98%80@www.example.com/',
243+
protocol: 'http:',
244+
auth: '\uD83D\uDE00',
245+
hostname: 'www.example.com',
246+
pathname: '/'
238247
}
239248
};
240249
for (const u in formatTests) {

0 commit comments

Comments
 (0)