diff --git a/src/utils/uuid.js b/src/utils/uuid.js index 83038e91..4524b160 100644 --- a/src/utils/uuid.js +++ b/src/utils/uuid.js @@ -3,8 +3,8 @@ import { customAlphabet } from 'nanoid'; // uuidv4 provides completely random values. (CSPRNG) // nanoid includes uppercase alphabets, making it more secure (completely random like uuidv4). // nanoid allows direct length adjustment in the function. -export const uid = () => - customAlphabet( - '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', - 15, - )(); +const ALPHABET = + '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; +const nanoid = customAlphabet(ALPHABET, 15); + +export const uid = () => nanoid(); diff --git a/src/utils/uuid.test.js b/src/utils/uuid.test.js index 2020d65d..7ac94f46 100644 --- a/src/utils/uuid.test.js +++ b/src/utils/uuid.test.js @@ -3,7 +3,7 @@ import { uid } from './uuid'; describe('uuid', () => { describe('createUUID', () => { - it('should create a UUID string of length 8', () => { + it('should create a UUID string of length 15', () => { const uuid = uid(); expect(uuid).toHaveLength(15); });