Fixed regex bug in Safari (#89399) (#89421)

* Fixed regex bug in Safari

* Added extra unit test
This commit is contained in:
Thom Heymann 2021-01-28 00:00:22 +00:00 committed by GitHub
parent fb74c3cfeb
commit aaed92a0a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -29,7 +29,7 @@ export const NEXT_URL_QUERY_STRING_PARAMETER = 'next';
* - Must contain only letters, numbers, spaces, punctuation and printable symbols.
* - Must not contain leading or trailing spaces.
*/
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]+(?<! )$/;
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]*[a-zA-Z0-9!"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]$/;
/**
* Maximum length of usernames and role names.

View file

@ -88,6 +88,12 @@ describe('CreateUserPage', () => {
await findAllByText(/Username must not contain leading or trailing spaces/i);
fireEvent.change(await findByLabelText('Username'), {
target: { value: 'username_with_trailing_space ' },
});
await findAllByText(/Username must not contain leading or trailing spaces/i);
fireEvent.change(await findByLabelText('Username'), {
target: { value: '€' },
});