summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/constants.jsx6
-rw-r--r--web/react/utils/utils.jsx19
2 files changed, 22 insertions, 3 deletions
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index d0f34293f..5d6aa9329 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -453,5 +453,9 @@ export default {
description: 'Show preview snippet of links below message'
}
},
- OVERLAY_TIME_DELAY: 400
+ OVERLAY_TIME_DELAY: 400,
+ MIN_USERNAME_LENGTH: 3,
+ MAX_USERNAME_LENGTH: 15,
+ MIN_PASSWORD_LENGTH: 5,
+ MAX_PASSWORD_LENGTH: 50
};
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 24042321f..71fd0852b 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -879,8 +879,8 @@ export function isValidUsername(name) {
var error = '';
if (!name) {
error = 'This field is required';
- } else if (name.length < 3 || name.length > 15) {
- error = 'Must be between 3 and 15 characters';
+ } else if (name.length < Constants.MIN_USERNAME_LENGTH || name.length > Constants.MAX_USERNAME_LENGTH) {
+ error = 'Must be between ' + Constants.MIN_USERNAME_LENGTH + ' and ' + Constants.MAX_USERNAME_LENGTH + ' characters';
} else if (!(/^[a-z0-9\.\-\_]+$/).test(name)) {
error = "Must contain only letters, numbers, and the symbols '.', '-', and '_'.";
} else if (!(/[a-z]/).test(name.charAt(0))) { //eslint-disable-line no-negated-condition
@@ -1101,6 +1101,17 @@ export function getFileName(path) {
return split[split.length - 1];
}
+// Gets the websocket port to use. Configurable on the server.
+export function getWebsocketPort(protocol) {
+ if ((/^wss:/).test(protocol)) { // wss://
+ return ':' + global.window.mm_config.WebsocketSecurePort;
+ }
+ if ((/^ws:/).test(protocol)) {
+ return ':' + global.window.mm_config.WebsocketPort;
+ }
+ return '';
+}
+
export function getSessionIndex() {
if (global.window.mm_session_token_index >= 0) {
return 'session_token_index=' + global.window.mm_session_token_index;
@@ -1309,6 +1320,10 @@ export function fillArray(value, length) {
// Checks if a data transfer contains files not text, folders, etc..
// Slightly modified from http://stackoverflow.com/questions/6848043/how-do-i-detect-a-file-is-being-dragged-rather-than-a-draggable-element-on-my-pa
export function isFileTransfer(files) {
+ if (isBrowserIE()) {
+ return files.types != null && files.types.contains('Files');
+ }
+
return files.types != null && (files.types.indexOf ? files.types.indexOf('Files') !== -1 : files.types.contains('application/x-moz-file'));
}