diff --git a/lib/transport.js b/lib/transport.js index 4e0f4a9d8..cfb51a4c3 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -50,13 +50,6 @@ function Transport (opts) { Emitter(Transport.prototype); -/** - * A counter used to prevent collisions in the timestamps used - * for cache busting. - */ - -Transport.timestamps = 0; - /** * Emits an error. * diff --git a/lib/transports/polling.js b/lib/transports/polling.js index aa3955744..218d1eb8a 100644 --- a/lib/transports/polling.js +++ b/lib/transports/polling.js @@ -6,6 +6,7 @@ var Transport = require('../transport'); var parseqs = require('parseqs'); var parser = require('engine.io-parser'); var inherit = require('component-inherit'); +var yeast = require('yeast'); var debug = require('debug')('engine.io-client:polling'); /** @@ -221,7 +222,7 @@ Polling.prototype.uri = function(){ // cache busting is forced if (false !== this.timestampRequests) { - query[this.timestampParam] = +new Date + '-' + Transport.timestamps++; + query[this.timestampParam] = yeast(); } if (!this.supportsBinary && !query.sid) { diff --git a/lib/transports/websocket.js b/lib/transports/websocket.js index 624a483b0..e95531393 100644 --- a/lib/transports/websocket.js +++ b/lib/transports/websocket.js @@ -6,6 +6,7 @@ var Transport = require('../transport'); var parser = require('engine.io-parser'); var parseqs = require('parseqs'); var inherit = require('component-inherit'); +var yeast = require('yeast'); var debug = require('debug')('engine.io-client:websocket'); /** @@ -229,7 +230,7 @@ WS.prototype.uri = function(){ // append timestamp to URI if (this.timestampRequests) { - query[this.timestampParam] = +new Date; + query[this.timestampParam] = yeast(); } // communicate binary support capabilities diff --git a/package.json b/package.json index 0c7312d3d..f705a2d4f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "parseuri": "0.0.4", "parsejson": "0.0.1", "parseqs": "0.0.2", - "component-inherit": "0.0.3" + "component-inherit": "0.0.3", + "yeast": "0.1.2" }, "devDependencies": { "blob": "0.0.2", diff --git a/test/transport.js b/test/transport.js index e2dca96e6..fe4690774 100644 --- a/test/transport.js +++ b/test/transport.js @@ -114,7 +114,7 @@ describe('Transport', function () { , timestampParam: 't' , timestampRequests: true }); - expect(polling.uri()).to.match(/http:\/\/localhost\/engine\.io\?(j=[0-9]+&)?(t=[0-9]+)/); + expect(polling.uri()).to.match(/http:\/\/localhost\/engine\.io\?(j=[0-9]+&)?(t=[0-9A-Za-z-_]+)/); }); it('should generate a ws uri', function () { @@ -146,7 +146,7 @@ describe('Transport', function () { , timestampParam: 'woot' , timestampRequests: true }); - expect(ws.uri()).to.match(/ws:\/\/localhost\/engine\.io\?woot=[0-9]+/); + expect(ws.uri()).to.match(/ws:\/\/localhost\/engine\.io\?woot=[0-9A-Za-z-_]+/); }); });