Browse Source

update MIME type detection

PHP-GTK3
yggverse 5 months ago
parent
commit
0183d4dbb4
  1. 29
      src/Model/Connection/File.php
  2. 16
      src/Model/Connection/Nex.php

29
src/Model/Connection/File.php

@ -86,30 +86,23 @@ class File
) )
); );
$this->_connection->setMime( // Detect MIME type
strval( switch (true)
mime_content_type( {
case $mime = Filesystem::getMimeByPath(
$address->getPath() $address->getPath()
) ): break;
)
);
if (Filesystem::MIME_TEXT_PLAIN == $this->_connection->getMime()) case $mime = mime_content_type(
{
$extension = pathinfo(
strval(
$address->getPath() $address->getPath()
), ): break;
PATHINFO_EXTENSION
); default: $mime = Filesystem::MIME_TEXT_GEMINI;
}
if (in_array($extension, ['gmi', 'gemini']))
{
$this->_connection->setMime( $this->_connection->setMime(
Filesystem::MIME_TEXT_GEMINI $mime
); );
}
}
break; break;

16
src/Model/Connection/Nex.php

@ -43,8 +43,22 @@ class Nex
$response $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( $this->_connection->setMime(
Filesystem::MIME_TEXT_PLAIN $mime
); );
} }

Loading…
Cancel
Save