You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is largely a question of return on investment. The regex has been good enough for a number of years. A small tweak will fix it for this new case. Replacing the code with a full DOM parsing approach is certainly doable, but will require a lot of changes to the existing code rather than one strategic tweak to the regex.
Longer term there is a plan to pull out the node parsing code into a shared library that can be reused by this tool, the flow-library and Node-RED itself - each of which have a slightly different set of requirements on what information gets pulled out. That would be the place to consider an alternative approach to the parsing.
Activity
sammachin commentedon Feb 4, 2022
@hardillb I think this is something you could look at in your node parsing library
hardillb commentedon Feb 4, 2022
Try this:
/<script.?(?:type=['"]text\/javascript['"])?\s?>([\S\s]*?)<\/script>/igIt probably needs a little more work, but that should match both
<script type="text/javascript">And
<script>Alkarex commentedon Feb 4, 2022
A regex will never be robust for such cases. A proper DOM parsing + XPath or CSS query would be better
knolleary commentedon Feb 4, 2022
It is largely a question of return on investment. The regex has been good enough for a number of years. A small tweak will fix it for this new case. Replacing the code with a full DOM parsing approach is certainly doable, but will require a lot of changes to the existing code rather than one strategic tweak to the regex.
Longer term there is a plan to pull out the node parsing code into a shared library that can be reused by this tool, the flow-library and Node-RED itself - each of which have a slightly different set of requirements on what information gets pulled out. That would be the place to consider an alternative approach to the parsing.
Update regex