Skip to content

Commit

Permalink
增加后缀名限制支持
Browse files Browse the repository at this point in the history
  • Loading branch information
breath-co2 committed Jan 7, 2013
1 parent 0f51bd6 commit ddb9aed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bin/merge-assets
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ foreach (Bootstrap::$include_path as $path)
$include_path = Bootstrap::$include_path;
$include_path = array_reverse($include_path);

# 允许的后缀
$allow_suffix = Core::config('core.asset_allow_suffix');
if (!$allow_suffix)
{
$allow_suffix = 'js|css|jpg|jpeg|png|gif|bmp|pdf|html|htm|mp4|swf';
}
$allow_suffix = explode('|',$allow_suffix);


# 循环获取所有文件列表
$file_paths = array();

Expand Down Expand Up @@ -475,6 +484,8 @@ exit;
*/
function glob_files(&$file_paths,$dir,$dir_len)
{
global $allow_suffix;

$files = glob( $dir .'*', GLOB_NOSORT );

if ($files)foreach ($files as $file)
Expand Down Expand Up @@ -557,15 +568,11 @@ function glob_files(&$file_paths,$dir,$dir_len)

$file_paths[$suffix][$file_path] = $file;
}
else
elseif (in_array($suffix,$allow_suffix))
{
$file_paths['other'][$file_path] = $file;
}
}
else
{
$file_paths['other'][$file_path] = $file;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions config.new.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@
$config['error500']['type_config'] = 'default';


/**
* assets允许的文件后缀名,用|隔开
*
*
* @var string
*/
$config['asset_allow_suffix'] = 'js|css|jpg|jpeg|png|gif|bmp|pdf|html|htm|mp4|swf';

/**
* nodejs 执行文件默认路径
Expand Down

0 comments on commit ddb9aed

Please sign in to comment.