Files
server/lib/rand_id.js
Roman Shtylman a2a58f4c6f refactor with async/await
Trying to be more robust about error handling and failure.
2016-07-09 17:06:13 -07:00

14 lines
345 B
JavaScript

// all url safe
// can't use uppercase because hostnames are lowercased
const chars = 'abcdefghijklmnopqrstuvwxyz';
export default function rand_id() {
let randomstring = '';
for (var i=0; i<10; ++i) {
const rnum = Math.floor(Math.random() * chars.length);
randomstring += chars[rnum];
}
return randomstring;
}