UNPKG

@rahmatsaeedi/miniurl

Version:

A full stack, light-weight, simplified, & minified version of bit.ly, that allows users to shorten long URLs

16 lines (12 loc) 424 B
module.exports = { generateRandomString: (length = 7) => { let array = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; let randString = ''; randString += array[Math.floor(Math.random() * array.length)]; array += "0123456789"; while (randString.length < length) { randString += array[Math.floor(Math.random() * array.length)]; } return randString; } };