File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -198,15 +198,25 @@ protected function stripComments()
198198 // PHP only supports $this inside anonymous functions since 5.4
199199 $ minifier = $ this ;
200200 $ callback = function ($ match ) use ($ minifier ) {
201- $ count = count ($ minifier ->extracted );
202- $ placeholder = '/* ' .$ count .'*/ ' ;
203- $ minifier ->extracted [$ placeholder ] = $ match [0 ];
201+ if (
202+ substr ($ match [1 ], 0 , 1 ) === '! ' ||
203+ strpos ($ match [1 ], '@license ' ) !== false ||
204+ strpos ($ match [1 ], '@preserve ' ) !== false
205+ ) {
206+ // preserve multi-line comments that start with /*!
207+ // or contain @license or @preserve annotations
208+ $ count = count ($ minifier ->extracted );
209+ $ placeholder = '/* ' .$ count .'*/ ' ;
210+ $ minifier ->extracted [$ placeholder ] = $ match [0 ];
211+
212+ return $ placeholder ;
213+ }
204214
205- return $ placeholder ;
215+ return '' ;
206216 };
217+
207218 // multi-line comments
208- $ this ->registerPattern ('/\n?\/\*(!|.*?@license|.*?@preserve).*?\*\/\n?/s ' , $ callback );
209- $ this ->registerPattern ('/\/\*.*?\*\//s ' , '' );
219+ $ this ->registerPattern ('/\n?\/\*(.*?)\*\/\n?/s ' , $ callback );
210220
211221 // single-line comments
212222 $ this ->registerPattern ('/\/\/.*$/m ' , '' );
You can’t perform that action at this time.
0 commit comments