asyncLiz / minify-html-literals

Minify HTML template literal strings
MIT License
68 stars 13 forks source link

Update strategy.ts #29

Closed CheloXL closed 3 years ago

CheloXL commented 3 years ago

Fixes #28. The original RegExp split method was not working as it needs to properly escape rx delimiters, etc. Added RX escape method and replaced the old string.split with the new RX split.

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 81


Files with Coverage Reduction New Missed Lines %
index.ts 1 50.0%
src/minifyHTMLLiterals.ts 55 2.42%
<!-- Total: 56 -->
Totals Coverage Status
Change from base Build 77: -74.9%
Covered Lines: 4
Relevant Lines: 64

💛 - Coveralls
asyncLiz commented 3 years ago

Thanks for the PR! It looks like I had originally investigated this but never finished the implementation.

The problem with my original idea (just passing the string to RegExp to make the last semicolon optional) as you found out is that the parens are special characters and are not escaped. While this approach works, I'd like to try and stick with simple string splitting, rather than introduce any new potential complexity with the RegExp class (especially if others are overriding the getPlaceholder method).

I've pushed a fix to the main branch and will release an update shortly. Thanks again for the report!