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

replaceMentionValues not working with multi mentions inside string #95

Open
fukemy opened this issue Jul 27, 2022 · 5 comments
Open

replaceMentionValues not working with multi mentions inside string #95

fukemy opened this issue Jul 27, 2022 · 5 comments

Comments

@fukemy
Copy link

fukemy commented Jul 27, 2022

for example i have below string:

@[demo5](d3f0c3cd-f363-4303-8761-8e190f054be3) @[demo8](8dbafd40-b86f-490a-828d-d11dfe221b43) test

then

params.Msg.Text = replaceMentionValues(text, ({name}) =>  `@${name}`)

result:
@demo5 @[demo8](8dbafd40-b86f-490a-828d-d11dfe221b43) test

@pgrepds
Copy link

pgrepds commented Jul 27, 2022

I can reproduce this issue. The issue appears only in 3.0.0-alpha.2. It works in 3.0.0-alpha.1.

@fukemy
Copy link
Author

fukemy commented Jul 27, 2022

thanks, @dabakovich plz update the problem

@fukemy fukemy closed this as completed Jul 27, 2022
@fukemy
Copy link
Author

fukemy commented Jul 27, 2022

waiting. for @dabakovich confirm

@fukemy fukemy reopened this Jul 27, 2022
@pgrepds
Copy link

pgrepds commented Jul 27, 2022

The cause of this issue is located in constraints.ts in 3.0.0-alpha.2 which defines the following regex: const mentionRegEx = /((.)\[([^[]*)]\(([^(^)]*)\))/i;. In 3.0.0-alpha.1 the used regex is located in utils.ts and is as follows: const mentionRegEx = /((.)\[([^[]*)]\(([^(^)]*)\))/gi;. The delimiter is not global anymore, thus not all words will be matched.

@pgrepds
Copy link

pgrepds commented Jul 27, 2022

It seems to be fixed in the newest version of the 3.0 branch. The function is renamed to replaceTriggerValues and adds the g to the regex. There is a test case in utils.test. I guess you can either downgrade to alpha 1 or use the newest version of the 3.0 branch (but the matching pattern seems to have changed a little bit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants