Skip to content

Commit 15a414e

Browse files
committed
add split limit to url and punycode
1 parent 3afa0aa commit 15a414e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/punycode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function map(array, callback) {
8282
* function.
8383
*/
8484
function mapDomain(domain, callback) {
85-
const parts = domain.split('@');
85+
const parts = domain.split('@', 2);
8686
let result = '';
8787
if (parts.length > 1) {
8888
// In email addresses, only the domain name should be punycoded. Leave

lib/url.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,10 @@ Url.prototype.resolveObject = function resolveObject(relative) {
886886
// This especially happens in cases like
887887
// url.resolveObject('mailto:local1@domain1', 'local2@domain2')
888888
const authInHost =
889-
result.host && result.host.indexOf('@') > 0 && result.host.split('@');
889+
result.host && result.host.indexOf('@') > 0 && result.host.split('@', 2);
890890
if (authInHost) {
891-
result.auth = authInHost.shift();
892-
result.host = result.hostname = authInHost.shift();
891+
result.auth = authInHost[0];
892+
result.host = result.hostname = authInHost[1];
893893
}
894894
}
895895
result.search = relative.search;
@@ -966,11 +966,10 @@ Url.prototype.resolveObject = function resolveObject(relative) {
966966
// Occasionally the auth can get stuck only in host.
967967
// This especially happens in cases like
968968
// url.resolveObject('mailto:local1@domain1', 'local2@domain2')
969-
const authInHost = result.host && result.host.indexOf('@') > 0 ?
970-
result.host.split('@') : false;
969+
const authInHost = result.host && result.host.indexOf('@') > 0 && result.host.split('@', 2);
971970
if (authInHost) {
972-
result.auth = authInHost.shift();
973-
result.host = result.hostname = authInHost.shift();
971+
result.auth = authInHost[0];
972+
result.host = result.hostname = authInHost[1];
974973
}
975974
}
976975

0 commit comments

Comments
 (0)