From 1336e844ff13f9c3cab853e9e9add2fa1e5bf1ff Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 8 Jul 2024 01:33:04 +0300 Subject: [PATCH] add content type detection by path extension --- .../Browser/Container/Tab/Page/Content.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Entity/Browser/Container/Tab/Page/Content.php b/src/Entity/Browser/Container/Tab/Page/Content.php index 2ff04d98..c392cc54 100644 --- a/src/Entity/Browser/Container/Tab/Page/Content.php +++ b/src/Entity/Browser/Container/Tab/Page/Content.php @@ -185,7 +185,7 @@ class Content $request->getResponse() ); - // Route status codes + // Route status code // https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes switch ($response->getCode()) { @@ -211,10 +211,24 @@ class Content case 20: // ok - // Process content type + // Detect content type switch (true) { - case str_contains($response->getMeta(), 'text/gemini'): + case str_contains( + $response->getMeta(), + 'text/gemini' + ): + + case in_array( + pathinfo( + $address->getPath(), + PATHINFO_EXTENSION + ), + [ + 'gmi', + 'gemini' + ] + ): $title = null;