Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
url: fix surrogate handling in encodeAuth()
  • Loading branch information
TimothyGu committed Feb 12, 2017
commit 8368389df9e71cb8e586f3fbddfcf6124b1c1642
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