From 57630adf90a347b47315614a63b750d4838911ae Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 24 Jul 2017 11:52:53 +0800 Subject: url: update sort() behavior with no params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/14185 Refs: https://github.com/whatwg/url/pull/336 Reviewed-By: Michaƫl Zasso Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- lib/internal/url.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/internal/url.js') diff --git a/lib/internal/url.js b/lib/internal/url.js index 6048777cfd..95b5e9c5fd 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1076,12 +1076,11 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', { sort() { const a = this[searchParams]; const len = a.length; - if (len <= 2) { - return; - } - // arbitrary number found through testing - if (len < 100) { + if (len <= 2) { + // Nothing needs to be done. + } else if (len < 100) { + // 100 is found through testing. // Simple stable in-place insertion sort // Derived from v8/src/js/array.js for (var i = 2; i < len; i += 2) { -- cgit v1.2.3