Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git
new/MediaTypeSniffer.php
private const EXTENSION_MAP = [
'txt' => [self::CAT_TEXT, 'text/plain'],
+ 'url' => [self::CAT_TEXT, 'text/plain'],
'html' => [self::CAT_TEXT, 'text/html'],
'htm' => [self::CAT_TEXT, 'text/html'],
public static function isBinary( string $data, string $filePath = '' ): bool {
- return self::isCategory( $data, $filePath ) !== self::CAT_TEXT;
+ [$category, $type] = self::getTypeInfo( $data, $filePath );
+ return $category !== self::CAT_TEXT && !str_starts_with( $type, 'text/' );
}
}

Detects text files properly

Author Dave Jarvis <email>
Date 2026-02-08 21:10:20 GMT-0800
Commit 53a4440cad42f53e0c093ba992e86729dd4b0d87
Parent 7d37972
Delta 3 lines added, 1 line removed, 2-line increase