mirror of
https://github.com/mrclay/minify.git
synced 2025-08-15 10:34:02 +02:00
Allow sources to have null contentType if serve is given one
This commit is contained in:
@@ -652,9 +652,24 @@ class Minify {
|
||||
|
||||
$type = null;
|
||||
foreach ($this->sources as $source) {
|
||||
$sourceType = $source->getContentType();
|
||||
|
||||
if (!empty($options['contentType'])) {
|
||||
// just verify sources have null content type or match the options
|
||||
if ($sourceType !== null && $sourceType !== $options['contentType']) {
|
||||
// TODO better logging
|
||||
Minify_Logger::log('ContentType mismatch');
|
||||
|
||||
$this->sources = array();
|
||||
return $options;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === null) {
|
||||
$type = $source->getContentType();
|
||||
} elseif ($source->getContentType() !== $type) {
|
||||
$type = $sourceType;
|
||||
} elseif ($sourceType !== $type) {
|
||||
|
||||
// TODO better logging
|
||||
Minify_Logger::log('ContentType mismatch');
|
||||
@@ -663,10 +678,13 @@ class Minify {
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($options['contentType'])) {
|
||||
if (null === $type) {
|
||||
$type = 'text/plain';
|
||||
}
|
||||
$options['contentType'] = $type;
|
||||
}
|
||||
|
||||
// last modified is needed for caching, even if setExpires is set
|
||||
if (!isset($options['lastModifiedTime'])) {
|
||||
|
@@ -47,7 +47,7 @@ interface Minify_SourceInterface {
|
||||
/**
|
||||
* Get the content type
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentType();
|
||||
|
||||
|
Reference in New Issue
Block a user