From 25bcdee083bc779f73c860927f133c2c096356cd Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Tue, 12 May 2020 20:01:57 +0200 Subject: [PATCH] feat(front): use uuid for random ids --- package-lock.json | 25 ++++++++++++++++++++++--- package.json | 3 ++- src/js/main.js | 7 +++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c3c494..4b83249 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7683,6 +7683,12 @@ "psl": "^1.1.28", "punycode": "^2.1.1" } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true } } }, @@ -11249,6 +11255,11 @@ "psl": "^1.1.24", "punycode": "^1.4.1" } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" } } }, @@ -12794,9 +12805,9 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz", + "integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg==" }, "uws": { "version": "0.14.5", @@ -13604,6 +13615,14 @@ "requires": { "ansi-colors": "^3.0.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "webpack-merge": { diff --git a/package.json b/package.json index cbac34b..8186ec6 100644 --- a/package.json +++ b/package.json @@ -33,12 +33,13 @@ "express": "4.*", "formidable": "1.*", "fs-extra": "7.*", - "jquery-ui-rotatable": "^1.1.0", "html2canvas": "^1.0.0-rc.5", + "jquery-ui-rotatable": "^1.1.0", "js-yaml": "3.13.1", "jsdom": "^14.0.0", "pdfjs-dist": "^2.3.200", "socket.io": "2.*", + "uuid": "^8.1.0", "webdav": "^2.8.0" }, "devDependencies": { diff --git a/src/js/main.js b/src/js/main.js index 77dc050..5308502 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -10,16 +10,15 @@ import ReadOnlyService from "./services/ReadOnlyService"; import InfoService from "./services/InfoService"; import { getQueryVariable, getSubDir } from "./utils"; import ConfigService from "./services/ConfigService"; +import { v4 as uuidv4 } from "uuid"; let whiteboardId = getQueryVariable("whiteboardid"); const randomid = getQueryVariable("randomid"); if (randomid && !whiteboardId) { //set random whiteboard on empty whiteboardid - whiteboardId = Array(2) - .fill(null) - .map(() => Math.random().toString(36).substr(2)) - .join(""); + whiteboardId = uuidv4(); const urlParams = new URLSearchParams(window.location.search); + urlParams.delete("randomid"); urlParams.set("whiteboardid", whiteboardId); window.location.search = urlParams; }