markdown-to-jsx icon indicating copy to clipboard operation
markdown-to-jsx copied to clipboard

Possibly redundant regex

Open jthistle opened this issue 4 years ago • 1 comments

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.

jthistle avatar Oct 12 '19 09:10 jthistle

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

quantizor avatar Oct 20 '19 18:10 quantizor