From b4d91df767a6b2a910a46eca98a2aef58b6e120a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Sun, 25 Feb 2024 02:56:40 +0800 Subject: [PATCH] fix: skip when the mime-type cannot match due to file permissions (#725) --- yazi-plugin/preset/plugins/mime.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yazi-plugin/preset/plugins/mime.lua b/yazi-plugin/preset/plugins/mime.lua index 2dcc9efd..ff738cd8 100644 --- a/yazi-plugin/preset/plugins/mime.lua +++ b/yazi-plugin/preset/plugins/mime.lua @@ -1,9 +1,11 @@ +local SUPPORTED_TYPES = "application/audio/biosig/chemical/font/image/inode/message/model/rinex/text/vector/video/x-epoc/" + local M = {} local function match_mimetype(s) - local type, subtype = s:match("([-a-z]+/)([+-.a-zA-Z0-9]+)%s*$") - if string.find("application/audio/biosig/chemical/font/image/inode/message/model/rinex/text/vector/video/x-epoc/", type, 1, true) then - return type .. subtype + local type, sub = s:match("([-a-z]+/)([+-.a-zA-Z0-9]+)%s*$") + if type and sub and string.find(SUPPORTED_TYPES, type, 1, true) then + return type .. sub end end