[Pkg-javascript-commits] [sockjs-client] 05/350: Remove max parameter from util.random_string

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:02:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit ebda6c5531bb8283a537f3fcca9eb121a715b3bf
Author: David Benjamin <davidben at mit.edu>
Date:   Wed Jul 3 01:59:39 2013 -0400

    Remove max parameter from util.random_string
    
    The only place that uses it, trans-receiver-htmlfile.js, doesn't need it; it
    prepends 'a' to the front of the identifier, so numbers aren't a problem. This
    is a nuisance for making util.random_string use a real random number generator;
    values of max that aren't powers of two would bias towards some values.
    
    That caller doesn't really care anyway, but we may as well remove the
    unnecessary parameter.
---
 lib/trans-receiver-htmlfile.js  | 2 +-
 lib/utils.js                    | 4 ++--
 tests/html/src/unittests.coffee | 1 -
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/trans-receiver-htmlfile.js b/lib/trans-receiver-htmlfile.js
index 1de2453..e2e3dd3 100644
--- a/lib/trans-receiver-htmlfile.js
+++ b/lib/trans-receiver-htmlfile.js
@@ -25,7 +25,7 @@ var HtmlfileReceiver = function(url) {
     var that = this;
     utils.polluteGlobalNamespace();
 
-    that.id = 'a' + utils.random_string(6, 26);
+    that.id = 'a' + utils.random_string(6);
     url += ((url.indexOf('?') === -1) ? '?' : '&') +
         'c=' + escape(WPrefix + '.' + that.id);
 
diff --git a/lib/utils.js b/lib/utils.js
index 80b5a77..f2860d4 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -7,8 +7,8 @@
  */
 
 var random_string_chars = 'abcdefghijklmnopqrstuvwxyz0123456789_';
-utils.random_string = function(length, max) {
-    max = max || random_string_chars.length;
+utils.random_string = function(length) {
+    var max = random_string_chars.length;
     var i, ret = [];
     for(i=0; i < length; i++) {
         ret.push( random_string_chars.substr(Math.floor(Math.random() * max),1) );
diff --git a/tests/html/src/unittests.coffee b/tests/html/src/unittests.coffee
index cf7b340..131bb1f 100644
--- a/tests/html/src/unittests.coffee
+++ b/tests/html/src/unittests.coffee
@@ -6,7 +6,6 @@ test 'random_string', ->
     notEqual(u.random_string(8), u.random_string(8))
     for i in [1,2,3,128]
         equal(u.random_string(i).length, i)
-    equal(u.random_string(4, 1), 'aaaa')
 
 test 'random_number_string', ->
     for i in [0..10]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list