Comparing version 0.0.1 to 0.0.2
16
index.js
@@ -14,2 +14,14 @@ /** | ||
/** | ||
* Make a Base64 string ready for use in URLs | ||
* | ||
* @param {String} | ||
* @returns {String} | ||
* @api private | ||
*/ | ||
function urlReady(str) { | ||
return str.replace(/\+/g, '_').replace(/\//g, '-'); | ||
} | ||
/** | ||
* Generate an Unique Id | ||
@@ -25,7 +37,7 @@ * | ||
if (typeof cb === 'undefined') { | ||
return crypto.randomBytes(numbytes).toString('base64').slice(0, length); | ||
return urlReady(crypto.randomBytes(numbytes).toString('base64').slice(0, length)); | ||
} else { | ||
crypto.randomBytes(numbytes, function(err, bytes) { | ||
if (err) return cb(err); | ||
cb(null, bytes.toString('base64').slice(0, length)); | ||
cb(null, urlReady(bytes.toString('base64').slice(0, length))); | ||
}) | ||
@@ -32,0 +44,0 @@ } |
@@ -5,5 +5,5 @@ { | ||
"tags": ["uid"], | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"dependencies": { | ||
} | ||
} |
1100
40