Skip to content

Fix: Username validation regex missing anchors #1201

@sudorishabh

Description

@sudorishabh

Description:

The current username validation regex /[0-9a-zA-Z-_.]+/ in EmbeddedChatApi.ts lacks start (^) and end ($) anchors. This causes the validation to pass for any string that contains at least one valid character, even if the rest of the string is invalid.

Steps to reproduce:

  1. Call updateUserUsername(userid, "@#$a@#$").
  2. Observe that usernameRegExp.test(newUserName) returns true because it matches the character "a".
  3. The method proceeds to attempt an update with an invalid username format.

Expected behavior:

The validation should fail if the string contains any characters outside the allowed set [0-9a-zA-Z-_.].

Actual behavior:

The validation passes if at least one character in the string matches the regex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions