Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API 调整:websocket 中间件 Proxy 接口上的 pattern 参数,避免误用 #713

Open
chuan6 opened this issue Mar 15, 2020 · 0 comments
Assignees
Labels

Comments

@chuan6
Copy link
Contributor

chuan6 commented Mar 15, 2020

比如现在用户给出 pattern :new:project,可以匹配 :new:projects:new:projecttags,但如果用户真正希望匹配的只是 :new:projects,在简单自测时

  1. 不容易发现自己少写了 s
  2. 更不容易发现会错误地匹配到 :new:projecttags(一方面用户不可能对全局的名单都熟悉,另外,字符串形式的接口可能会令用户误解,以为这里有目前没有实现的自动断词功能)。

如何避免误用?更具体地,如果增强用户简单自测(仅试一例)的效果?(该例失败,说明 pattern 无效;该例成功,说明 pattern 不仅有效,而且大概率不会错误匹配其他可能类似的 websocket 事件)

提议:

  1. 为简单字符串参数(不包含正则特殊符号)自动加 word boundary
  2. 提供重载方法,提示用户在复杂使用场景里直接写正则,从接口上告知用户,匹配得是否准确,完全取决于用户自己的正则是否写得完善

注:这个问题由 @AmosJin 发现,并在应用代码里先做了特殊处理(手动加 word boundary),谢谢 :)

@chuan6 chuan6 self-assigned this Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant