zoffixznet / JavaScript-Minifier

JavaScript::Minifier perl module
9 stars 6 forks source link

minify produces warning for empty files #3

Closed tmhall closed 10 years ago

tmhall commented 10 years ago

minify produces the following warning for empty files

Use of uninitialized value in pattern match (m//) at C:/strawberry/perl/site/lib/JavaScript/Minifier.pm line 345.

This is demonstrated by the following minimal example

perl -MJavaScript::Minifier=minify -e 'print minify(input => "")'

The easy fix for this is simply to verify that your hash key is defined before using it in a regex.

    if ( defined $s->{last_read_char} && $s->{last_read_char} =~ /\n/ ) {
        _put($s, "\n");
    }

I discovered this bug because of this SO post: How do i minify all js files within a directory structure using javascipt::minify module?

zoffixznet commented 10 years ago

Thanks for the report and fix. I'll patch up the module and re-release soon.

tmhall commented 10 years ago

Thanks for the heads up.

I'll keep an eye on metacpan for when you push the release.

On Sat, Sep 27, 2014 at 3:23 PM, Zoffix Znet notifications@github.com wrote:

Thanks for the report and fix. I'll patch up the module and re-release soon.

— Reply to this email directly or view it on GitHub https://github.com/zoffixznet/JavaScript-Minifier/issues/3#issuecomment-57067742 .