peers/peerjs

Seemingly valid peer ids rejected by validateId function

Open

#849 建立於 2021年5月19日

在 GitHub 查看
 (1 留言) (2 反應) (0 負責人)TypeScript (1,406 fork)batch import
bugclientconfirmedhelp wanted

倉庫指標

Star
 (11,580 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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]$

貢獻者指南