mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
relax username validation (#413)
this commit allows for matching accented characters, dots, '@' symbol, and other important things.
This commit is contained in:
@@ -94,7 +94,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
isUserNameValid: function(name) {
|
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) {
|
isPasswordValid: function(password) {
|
||||||
|
|||||||
12
tests/utils.js
Normal file
12
tests/utils.js
Normal file
@@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user