Seemingly valid peer ids rejected by validateId function #849
Labels
bug
client
related to peerjs client
confirmed
acknowledged as an issue
help wanted
looking for contributors
The API documentation states:
The ID must start and end with an alphanumeric character (lower or upper case character or a digit). In the middle of the ID spaces, dashes (-) and underscores (_) are allowed.
Problem:
According to the documentation the below ids should be valid but instead throw the error "invalid-id". The docs fail to mention that spaces, dashes, and underscores cannot be next to each other.
acb123_-xyz
acb123__xyz
acb123--xyz
acb123 -xyz
Solution:
If there is no functional reason for this limitation the validateId function regex could be updated to reflect the documentation. Alternatively the documentation could be amended.
The regex that validate the peer id is currently:
^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$
Updated regex to match documentation:
^[A-Za-z0-9][A-Za-z0-9_- ]*[A-Za-z0-9]$
The text was updated successfully, but these errors were encountered: