summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-08-10 12:05:45 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-08-10 14:04:23 -0400
commitc9a1bf2d336cc5718cdf327f37cfdf87dc0e2705 (patch)
treed90cdfebf96ac6a4557a8caaefe06888b7d9d6ba /web/react/utils
parent4b74c873cc95973c5434988a41f5e06446a4e586 (diff)
downloadchat-c9a1bf2d336cc5718cdf327f37cfdf87dc0e2705.tar.gz
chat-c9a1bf2d336cc5718cdf327f37cfdf87dc0e2705.tar.bz2
chat-c9a1bf2d336cc5718cdf327f37cfdf87dc0e2705.zip
Changed post drafts to maintain a store a unique id for each file upload to fix issues with duplicate file names
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/utils.jsx21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index a759cc579..2214b6239 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -913,3 +913,24 @@ module.exports.getFileName = function(path) {
var split = path.split('/');
return split[split.length - 1];
};
+
+// Generates a RFC-4122 version 4 compliant globally unique identifier.
+module.exports.generateId = function() {
+ // implementation taken from http://stackoverflow.com/a/2117523
+ var id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
+
+ id = id.replace(/[xy]/g, function(c) {
+ var r = Math.floor(Math.random() * 16);
+
+ var v;
+ if (c === 'x') {
+ v = r;
+ } else {
+ v = r & 0x3 | 0x8;
+ }
+
+ return v.toString(16);
+ });
+
+ return id;
+};