Skip to content

Commit

Permalink
Change default id generator to be RFC4122 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
tedeh committed Jul 14, 2013
1 parent 83be9de commit b36895e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/utils.js
Expand Up @@ -79,7 +79,10 @@ Utils.response = function(error, result, id, version) {
* @api public * @api public
*/ */
Utils.generateId = function() { Utils.generateId = function() {
return Math.round(Math.random() * Math.pow(2, 24)); return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}; };


/** /**
Expand Down

0 comments on commit b36895e

Please sign in to comment.