Skip to content

Commit 858cb41

Browse files
fix: Repeat random-utils base string to avoid Math.random to return the same character twice
1 parent 1f02575 commit 858cb41

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/random-utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export const alphanum = 'abcdefghijklmnopqrstuvwyz0123456789'
1+
const alphanumBase = 'abcdefghijklmnopqrstuvwyz0123456789'
2+
// We need to duplicate the base string to have a longer string
3+
// to avoid Math.random to return the same value twice
4+
export const alphanum = alphanumBase.repeat(10)
25

36
export const getRandomAlphaNum = () => {
47
const randomIndex = Math.floor(Math.random() * alphanum.length)

0 commit comments

Comments
 (0)