Skip to content

Commit

Permalink
url: fix surrogate handling in encodeAuth()
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyGu committed Feb 12, 2017
1 parent 4cafa60 commit 8368389
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ function encodeAuth(str) {
}
// Surrogate pair
++i;
++lastPos;
var c2;
if (i < str.length)
c2 = str.charCodeAt(i) & 0x3FF;
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-url-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ const formatTests = {
protocol: 'file',
pathname: '/home/user',
path: '/home/user'
},

// surrogate in auth
'http://%F0%9F%98%80@www.example.com/': {
href: 'http://%F0%9F%98%80@www.example.com/',
protocol: 'http:',
auth: '\uD83D\uDE00',
hostname: 'www.example.com',
pathname: '/'
}
};
for (const u in formatTests) {
Expand Down

0 comments on commit 8368389

Please sign in to comment.