From 6fb772944cf829a126c82b6404295a6d8867f8dc Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 23 Sep 2019 18:55:38 +0000 Subject: [PATCH] feat: expanded allowed characters in usernames to support accents (#2585) --- src/core/common/helpers/validate.spec.ts | 20 ++++++++++++++++++++ src/core/common/helpers/validate.ts | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/core/common/helpers/validate.spec.ts diff --git a/src/core/common/helpers/validate.spec.ts b/src/core/common/helpers/validate.spec.ts new file mode 100644 index 000000000..74b1719e2 --- /dev/null +++ b/src/core/common/helpers/validate.spec.ts @@ -0,0 +1,20 @@ +import { USERNAME_REGEX } from "./validate"; + +describe("USERNAME_REGEX", () => { + it("validates username characters", () => { + const usernames = [ + "bill", + "bill.smith", + "bill_smith", + "bill.smith13", + "áki", + "åki.smith", + "åki.smith13", + "åki_smith", + ]; + + usernames.forEach(username => { + expect(USERNAME_REGEX.test(username)).toEqual(true); + }); + }); +}); diff --git a/src/core/common/helpers/validate.ts b/src/core/common/helpers/validate.ts index 42829adfb..a1789f1d8 100644 --- a/src/core/common/helpers/validate.ts +++ b/src/core/common/helpers/validate.ts @@ -1,6 +1,6 @@ import url from "url-regex"; -export const USERNAME_REGEX = new RegExp(/^[a-zA-Z0-9_.]+$/); +export const USERNAME_REGEX = new RegExp(/^[a-zA-ZÀ-ÖØ-öø-ÿ0-9_.]+$/); export const USERNAME_MAX_LENGTH = 30; export const USERNAME_MIN_LENGTH = 3;