Skip to content

Commit

Permalink
url: improve parsing speed
Browse files Browse the repository at this point in the history
The url.parse() function now checks whether an escapable character is
in the URL before trying to escape it.

PR-URL: nodejs/node-v0.x-archive#8638
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
CGavrila authored and bnoordhuis committed Dec 6, 2014
1 parent 244a8f7 commit 36aeae8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,13 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
// need to be.
for (var i = 0, l = autoEscape.length; i < l; i++) {
var ae = autoEscape[i];
var esc = encodeURIComponent(ae);
if (esc === ae) {
esc = escape(ae);
if (rest.indexOf(ae) !== -1) {
var esc = encodeURIComponent(ae);
if (esc === ae) {
esc = escape(ae);
}
rest = rest.split(ae).join(esc);
}
rest = rest.split(ae).join(esc);
}
}

Expand Down

0 comments on commit 36aeae8

Please sign in to comment.