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

Issue in data-parsley-pattern when using unicode escape character 'u'. #1373

Open
1 of 3 tasks
choppercoder opened this issue Mar 19, 2024 · 0 comments
Open
1 of 3 tasks

Comments

@choppercoder
Copy link

choppercoder commented Mar 19, 2024

What kind of issue is this? (put 'x' between the square brackets)

Suppose I have a data object with regex in it, that is being fetched from an api, in the form-
data = {regex : "/^[\p{L} .’_-]+$/u"}

If I assign data-parsley-pattern = data.regex, parsley.js transforms it into a format that always results to false where converted= /^/^[\p{L} .’-]+$/u$/
If I directly assign data.regex= /^[\p{L} .’
-]+$/u then it works fine.
I have tried to converted the stringified regex to object before assigning it, but nothing seems to work. the regex is always changed into something that gives the validation result as false even if value is correct.

The code I used to convert stringified regex to regex object is given here-

const data = { regex : "/^[\p{L} .’_-]+$/u" };
const [, regex, flags] = data.regex.match(/^/(.)/([a-z])$/);
const pattern = new RegExp(regex, flags);
console.log(pattern.test('check')); //this results to true

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