From 5cba16fcce1b12eb752712690b6749bf913137a9 Mon Sep 17 00:00:00 2001 From: Alexander ADAM Date: Fri, 10 Oct 2025 23:17:46 +0200 Subject: [PATCH] improve HTML detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before anything, that contained a starting HTML tag was identified as an HTML. This patch should make the detection a little more robust. 🤞 See issue #102 for more details --- lib/marcel/mime_type/definitions.rb | 23 ++++++++++++++++++- test/fixtures/name/application/json/json.json | 3 ++- test/fixtures/name/text/csv/csv.csv | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/marcel/mime_type/definitions.rb b/lib/marcel/mime_type/definitions.rb index 09ce72b..fe68b5f 100644 --- a/lib/marcel/mime_type/definitions.rb +++ b/lib/marcel/mime_type/definitions.rb @@ -1,7 +1,28 @@ # frozen_string_literal: true Marcel::MimeType.extend "text/plain", extensions: %w( txt asc ) -Marcel::MimeType.extend "text/html", magic: [[0..64, "" } diff --git a/test/fixtures/name/text/csv/csv.csv b/test/fixtures/name/text/csv/csv.csv index 083fb14..0cad418 100644 --- a/test/fixtures/name/text/csv/csv.csv +++ b/test/fixtures/name/text/csv/csv.csv @@ -1,2 +1,2 @@ -Name,Age,Occupation -Marcel Marceau,94,Mime \ No newline at end of file +Name,Age,Occupation,Quote +Marcel Marceau,94,Mime,I used to develop in a lot but now it's just some that I used to know