Skip to content

Commit 6a03fce

Browse files
CGavrilatrevnorris
authored andcommitted
url: improve parsing speed
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 [[email protected]: Switch to use continue instead of if] Signed-off-by: Trevor Norris <[email protected]>
1 parent 890baa0 commit 6a03fce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/url.js

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
318318
// need to be.
319319
for (var i = 0, l = autoEscape.length; i < l; i++) {
320320
var ae = autoEscape[i];
321+
if (rest.indexOf(ae) === -1)
322+
continue;
321323
var esc = encodeURIComponent(ae);
322324
if (esc === ae) {
323325
esc = escape(ae);

0 commit comments

Comments
 (0)