Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/utils/uuid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion src/utils/uuid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down