From 5945ab1a0aa3e5dcf0d3326d75db4fa0bb08cc5e Mon Sep 17 00:00:00 2001 From: Noah Chase Date: Sat, 19 Oct 2013 13:11:28 -0400 Subject: [PATCH] relax username validation (#413) this commit allows for matching accented characters, dots, '@' symbol, and other important things. --- public/src/utils.js | 2 +- tests/utils.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/utils.js diff --git a/public/src/utils.js b/public/src/utils.js index c99fbb99a3..6b9343ee95 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -94,7 +94,7 @@ }, isUserNameValid: function(name) { - return (name && name !== "" && (/^[a-zA-Z0-9 _-]+$/.test(name))); + return (name && name !== "" && (/^['"\s\-.*0-9\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(name))); }, isPasswordValid: function(password) { diff --git a/tests/utils.js b/tests/utils.js new file mode 100644 index 0000000000..70643802f8 --- /dev/null +++ b/tests/utils.js @@ -0,0 +1,12 @@ +var assert = require('assert'), + utils = require('./../public/src/utils.js'); + + +describe("Utility Methods", function(){ + describe("username validation", function(){ + it("accepts latin-1 characters", function(){ + var username = "John\"'-. Doeäâèéë1234"; + assert(utils.isUserNameValid(username), 'invalid username'); + }); + }); +});