Closed zeruk closed 3 years ago
The event subscription didn't design to support regex, so it's not a bug, it can be an enhancement to support it.
But it supports :D
Example:
'qwer.(asd|fgh)?zxc'
after all the replacements it becomes '^qwer.(asd|fgh).zxc$'
Just from the code I attached in issue the regexp must have '?' sign, which then leads to be replaced with '.'
Prerequisites
Current Behavior
It is impossible to use RegExps which do not contain question sign(?) in events.
Expected Behavior
It is possible to use RegExps in events
Failure Information
It corresponds to code in https://github.com/moleculerjs/moleculer/blob/2f7d3d0d1a39511bc6bb9b71c6729326a3e8afad/src/utils.js#L268
Steps to Reproduce
Example: 1) try to emit event 'qwer.asd.zxc' 2) try to catch it at 'qwer.(asd|fgh).zxc'. 3) ??? (No, you can't)
Reproduce code snippet
https://codesandbox.io/s/moleculer-sample-forked-8rrk9?file=/index.js