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

Possibly redundant regex #270

Open
jthistle opened this issue Oct 12, 2019 · 1 comment
Open

Possibly redundant regex #270

jthistle opened this issue Oct 12, 2019 · 1 comment

Comments

@jthistle
Copy link

jthistle commented Oct 12, 2019

In this bit of regex

const HTML_BLOCK_ELEMENT_R = /^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/i;

This section: ([^>]*)\/{0} is meant to capture the attributes of an opening tag. I think that the \/{0} is redundant. The regex will have been matching anything apart from > in the previous capture group, so when it finishes matching that it will definitely be at a > character. Of course, a > is not /, so \/{0} is not needed - it's certain that there will be no / to match.

I may be wrong about this, however.

@quantizor
Copy link
Owner

Try removing it and see if the tests pass, heh.

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