Skip to content

Commit

Permalink
Fixes Issue 1, Do not minify files ending in .min.ext
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Jul 14, 2014
1 parent c04c9fd commit 3c8fabc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ public function getResponseForPath($path, Request $request)

$filePath = build_path($directory, $pathInfo['basename']);

//Do not minify files ending in .min.ext
if(substr($pathInfo['filename'], -4) == '.min')
{
$asset->setOption('minify', false);
}

//If the asset does not exist on disk, return a not found error
if($directory === null || !file_exists($filePath))
{
Expand Down
22 changes: 22 additions & 0 deletions tests/DispatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ public function urlProvider()
'url(\'//www.packaged.in/res/p/8cac7/b/d41d8cd/x.jpg\'); }'
];
$tests[] = [
array_merge($baseConfig, []),
'res/p/domain/b/filehash/test.js',
'www.packaged.in',
'function myFunction()
{alert("Hello\nHow are you?");}'
];

/**
* Do not minify .min.ext files
* @link https://github.com/packaged/dispatch/issues/1
* */
$tests[] = [
array_merge($baseConfig, []),
'res/p/domain/b/filehash/test.min.js',
'www.packaged.in',
'function myFunction()
{
alert("Hello\nHow are you?");
}'
];

$tests[] = [
array_merge($baseConfig, []),
'res/p/domain/b/filehash/test.css',
Expand Down
4 changes: 4 additions & 0 deletions tests/asset/test.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function myFunction()
{
alert("Hello\nHow are you?");
}

0 comments on commit 3c8fabc

Please sign in to comment.