diff --git a/ngx-http-concat.php b/ngx-http-concat.php index 36bc363..5a5c157 100644 --- a/ngx-http-concat.php +++ b/ngx-http-concat.php @@ -176,15 +176,15 @@ function concat_get_path( $uri ) { ); // The @charset rules must be on top of the output - if ( 0 === strpos( $buf, '@charset' ) ) { - preg_replace_callback( + if ( false !== strpos( $buf, '@charset' ) ) { + $buf = preg_replace_callback( '/(?P@charset\s+[\'"][^\'"]+[\'"];)/i', function ( $match ) { global $pre_output; if ( 0 === strpos( $pre_output, '@charset' ) ) return ''; - + $pre_output = $match[0] . "\n" . $pre_output; return '';