rstacruz / css-condense

[unsupported] A CSS compressor that shows no mercy
205 stars 4 forks source link

Fix regex bug giving TypeError in compressIdentifier #12

Closed ErikSwan closed 9 years ago

ErikSwan commented 9 years ago

There is a bug in the regular expression used in compressIdentifier: the numeric part of the identifier match is optional. If an identifier such as em or px is encountered without a number before the unit, num = m[1] is undefined and calling num.match(...) throws a TypeError.

Fixed by making the first matching group required, as there's nothing to compress if there's no value.