From 9b3f7a3f38ad9ebbd3e11b1d69cc958dac8ba1c6 Mon Sep 17 00:00:00 2001 From: Michelle Bu Date: Thu, 1 May 2014 21:05:11 -0700 Subject: [PATCH] Make IDs *always* 16 characters --- lib/util.js | 2 +- test/server.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 8a81cf1f8..213390bf8 100644 --- a/lib/util.js +++ b/lib/util.js @@ -22,7 +22,7 @@ var util = { return dest; }, randomId: function () { - return Math.random().toString(36).substr(2); + return (Math.random().toString(36) + '0000000000000000000').substr(2, 16); }, prettyError: function (msg) { if (util.debug) { diff --git a/test/server.js b/test/server.js index 9ce659d35..e40d858f6 100644 --- a/test/server.js +++ b/test/server.js @@ -206,7 +206,7 @@ describe('PeerServer', function() { }); it('should generate a 16-character ID', function() { - expect(p._generateClientId('anykey').length).to.be.within(15, 16); + expect(p._generateClientId('anykey').length).to.be(16); }); }); });