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

mentionDenotationChars if it is a special symbol regular match is not correct #365

Open
lginsane opened this issue Mar 18, 2024 · 0 comments

Comments

@lginsane
Copy link

file path: src/utils/index

const regex = new RegExp(`^${mentionChar}|\\s${mentionChar}`, "g");
const lastMatch = (text.match(regex) || []).pop();

If I set mentionChar to "this."

mention: {
  mentionDenotationChars: ["this."]
}

expect:
image

actual:
image

Execution result:
When I type "this" and anything, it matches "this.".

I solved this problem with the following changes:

const regex = new RegExp(`^${mentionChar}|\\s${mentionChar}`, "g");

Be modified into

const new_mentionChar = mentionChar.replace(/[^a-zA-Z0-9\u4e00-\u9fa5\s]/g,"\\$&");
const regex = new RegExp( `^${new_mentionChar}|\\s${new_mentionChar}`, "g");
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

1 participant