JShrink icon indicating copy to clipboard operation
JShrink copied to clipboard

Spaces in regular expressions get removed when they shouldn't

Open DonaldDuck313 opened this issue 5 years ago • 0 comments

I have the following Javascript code that I would like to minify with JShrink:

function airplaneIsCarrierBased(model){
    return /^(FI-167|Swordfish|Fulmar|Firefly|F4F Wildcat|F6F-[35] Hellcat|Latécoère 298|A[567]M)$/.test(model);
}

console.log(airplaneIsCarrierBased("F6F-5 Hellcat"));

This unminified code logs true as expected. But if I try to minify this with JShrink, the minified code will be this:

function airplaneIsCarrierBased(model){return /^(FI-167|Swordfish|Fulmar|Firefly|F4F Wildcat|F6F-[35]Hellcat|Latécoère 298|A[567]M)$/.test(model);}
console.log(airplaneIsCarrierBased("F6F-5 Hellcat"));

This logs false because JShrink removed the space in the regex between F6F-[35] and Hellcat. I spend hours trying to debug my Javascript before I realized there was a bug in the minifier. My current workaround is to use \s instead of a space, but it would be better if you could fix this bug so that JShrink doesn't remove that space.

DonaldDuck313 avatar Aug 17 '20 09:08 DonaldDuck313