diff --git a/src/Model/Connection/File.php b/src/Model/Connection/File.php index 987626dd..f06d2c26 100644 --- a/src/Model/Connection/File.php +++ b/src/Model/Connection/File.php @@ -86,31 +86,24 @@ class File ) ); - $this->_connection->setMime( - strval( - mime_content_type( - $address->getPath() - ) - ) - ); - - if (Filesystem::MIME_TEXT_PLAIN == $this->_connection->getMime()) + // Detect MIME type + switch (true) { - $extension = pathinfo( - strval( - $address->getPath() - ), - PATHINFO_EXTENSION - ); + case $mime = Filesystem::getMimeByPath( + $address->getPath() + ): break; + + case $mime = mime_content_type( + $address->getPath() + ): break; - if (in_array($extension, ['gmi', 'gemini'])) - { - $this->_connection->setMime( - Filesystem::MIME_TEXT_GEMINI - ); - } + default: $mime = Filesystem::MIME_TEXT_GEMINI; } + $this->_connection->setMime( + $mime + ); + break; default: diff --git a/src/Model/Connection/Nex.php b/src/Model/Connection/Nex.php index 201c4246..a65dac2d 100644 --- a/src/Model/Connection/Nex.php +++ b/src/Model/Connection/Nex.php @@ -43,8 +43,22 @@ class Nex $response ); + // Detect MIME type + switch (true) + { + case $mime = Filesystem::getMimeByPath( + $address->getPath() + ): break; + + case $mime = Filesystem::getMimeByData( + $response + ): break; + + default: $mime = Filesystem::MIME_TEXT_PLAIN; + } + $this->_connection->setMime( - Filesystem::MIME_TEXT_PLAIN + $mime ); }