Permalink
Browse files

Change default id generator to be RFC4122 compliant

  • Loading branch information...
tedeh committed Jul 14, 2013
1 parent 83be9de commit b36895e7f3afe05e0c3fe6398b81c3909a89bff3
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/utils.js
View
@@ -79,7 +79,10 @@ Utils.response = function(error, result, id, version) {
* @api public
*/
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);
+ });
};
/**

0 comments on commit b36895e

Please sign in to comment.