GuillaumeGomez / minifier-rs

Minifier tool/lib for JS/CSS/JSON files
MIT License
86 stars 16 forks source link

Incorrect minification with the `in` operator #41

Closed magiclen closed 5 years ago

magiclen commented 5 years ago

According to this page, the in operator returns true if the specified property is in the specified object or its prototype chain.

The 3-lines code should not to panic,

assert_eq!("t in e", minifier::js::minify("t in e"));
assert_eq!("t+1 in e", minifier::js::minify("t + 1 in e"));
assert_eq!("t-1 in e", minifier::js::minify("t - 1 in e"));

However, it panics after v0.0.27,

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"t+1 in e"`,
 right: `"t+1in e"`'

Also, I think 'make' in car should be minified to 'make' in car but not to 'make'in car, although the latter seems to be acceptable.

GuillaumeGomez commented 5 years ago

Thanks for the feedback! I'll try to fix it in the next hours.