CssMin icon indicating copy to clipboard operation
CssMin copied to clipboard

"RemoveComments" flag not work

Open brzlvch opened this issue 3 years ago • 0 comments

Filter adding "RemoveComments" does not remove comments (/ *! * /)

After adding the filter, the file looks like this

/ *!
   * Bootstrap v4.6.0 (https://getbootstrap.com/)
   * Copyright 2011-2021 Bootstrap Authors
   * Copyright 2011-2021 Twitter, Inc.
   * MIT License (https://github.com/twbs/bootstrap/blob/main/LICENSE)
   * /: root {- blue: # 007bff; - indigo: # 6610f2; - purple: # 6f42c1; - pink: # e83e8

...

I think that if in this line

https://github.com/natxet/CssMin/blob/master/src/CssMin.php#L1367

replace the code for conditions with (without !):

if (preg_match($this->whitelistPattern, $tokens[$i]->Comment))
{
    $tokens[$i] = null;
    $r++;
}

then the comment will be deleted

Environment:

PHP 7.1 natxet/CssMin 3.0.4

brzlvch avatar Aug 09 '21 09:08 brzlvch