Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/JS.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected function stripComments()
$this->registerPattern('/\/\*.*?\*\//s', '');

// single-line comments
$this->registerPattern('/\/\/.*$/m', '');
$this->registerPattern('/(\/\/)(?!i)(?!\.).*$/m', '');
}

/**
Expand Down
25 changes: 25 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,31 @@ function someOtherFunction() {
'/^\[(x| )\](?=\s)/i',
);

// https://github.com/matthiasmullie/minify/issues/323
$tests[] = array(
'a = {
device: [
[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7)/i],
[/(sony)\s(tablet\s[ps])\sbuild\//i, /(sony)?(?:sgp.+)\sbuild\//i],
[/(?:sony)?(?:(?:(?:c|d)\d{4})|(?:so[-l].+))\sbuild\//i]
]
}',
'a={device:[[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7)/i],[/(sony)\s(tablet\s[ps])\sbuild\//i,/(sony)?(?:sgp.+)\sbuild\//i],[/(?:sony)?(?:(?:(?:c|d)\d{4})|(?:so[-l].+))\sbuild\//i]]}'
);

// https://github.com/matthiasmullie/minify/issues/329
$tests[] = array(
'test: [/\sedg\//i],',
'test:[/\sedg\//i],',
);

// https://github.com/wp-media/wp-rocket/issues/2974
$tests[] = array(
'if(b)return w.IGNORE;var c=B(fb(a,"href"));b=R(fb(a,"hostname"));c=c?/^https?:\/\//.test(c)||/^\/\//.test(c):!1;if(c&&!lc(a)){if(la)return w.TRACK;
if(!0===p.aff_domains[b]||H(lb,b))return w.AFFILIATE;if(Ka(b))return w.PRE_AFFILIATED;',
'if(b)return w.IGNORE;var c=B(fb(a,"href"));b=R(fb(a,"hostname"));c=c?/^https?:\/\//.test(c)||/^\/\//.test(c):!1;if(c&&!lc(a)){if(la)return w.TRACK;if(!0===p.aff_domains[b]||H(lb,b))return w.AFFILIATE;if(Ka(b))return w.PRE_AFFILIATED'
);

// known minified files to help doublecheck changes in places not yet
// anticipated in these tests
$files = glob(__DIR__.'/sample/minified/*.js');
Expand Down