1
0
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:
Steve Clay
2015-09-29 13:18:10 -04:00
parent a566536f80
commit 12e7a8d0dd
2 changed files with 24 additions and 6 deletions

View File

@@ -652,9 +652,24 @@ class Minify {
$type = null; $type = null;
foreach ($this->sources as $source) { 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) { if ($type === null) {
$type = $source->getContentType(); $type = $sourceType;
} elseif ($source->getContentType() !== $type) { } elseif ($sourceType !== $type) {
// TODO better logging // TODO better logging
Minify_Logger::log('ContentType mismatch'); Minify_Logger::log('ContentType mismatch');
@@ -663,10 +678,13 @@ class Minify {
return $options; return $options;
} }
} }
if (null === $type) {
$type = 'text/plain'; if (empty($options['contentType'])) {
if (null === $type) {
$type = 'text/plain';
}
$options['contentType'] = $type;
} }
$options['contentType'] = $type;
// last modified is needed for caching, even if setExpires is set // last modified is needed for caching, even if setExpires is set
if (!isset($options['lastModifiedTime'])) { if (!isset($options['lastModifiedTime'])) {

View File

@@ -47,7 +47,7 @@ interface Minify_SourceInterface {
/** /**
* Get the content type * Get the content type
* *
* @return string * @return string|null
*/ */
public function getContentType(); public function getContentType();