From f9175e98b965c789d59dcbf4714b900040c15f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Thu, 22 Feb 2024 16:45:21 +0100 Subject: [PATCH] chore: change `generateID()` implementation --- umap/static/umap/js/modules/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/modules/utils.js b/umap/static/umap/js/modules/utils.js index 03081308..aa681602 100644 --- a/umap/static/umap/js/modules/utils.js +++ b/umap/static/umap/js/modules/utils.js @@ -1,7 +1,7 @@ /** - * Generate a pseudo-unique identifier (4 chars long) + * Generate a pseudo-unique identifier (5 chars long, mixed-case alphanumeric) * - * Using uppercase + lowercase + digits, here's the collision risk: + * Here's the collision risk: * - for 6 chars, 1 in 100 000 * - for 5 chars, 5 in 100 000 * - for 4 chars, 500 in 100 000 @@ -9,5 +9,5 @@ * @returns string */ export function generateId() { - return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) + return btoa(Math.random().toString()).substring(10, 15) }