Skip to content

Commit

Permalink
[Feature] Multimap: Also check detected charset when do filename checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Aug 2, 2019
1 parent f06ec9d commit 99cdd89
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/plugins/lua/multimap.lua
Expand Up @@ -865,8 +865,25 @@ local function multimap_callback(task, rule)
if fn then
match_filename(rule, fn)
end
-- Also deal with detected content type
local dtype,dsubtype = p:get_detected_type()
if not rule.skip_detected and (dtype and dsubtype) then
local detected_ct = string.format('%s/%s', dtype, dsubtype)

if detected_ct then
local lua_mime = require "lua_mime"

local ext = lua_mime.reversed_extensions_map[detected_ct]

if ext then
local fake_fname = string.format('detected.%s', ext)
match_filename(rule, fake_fname)
end
end
end
end
end,

content = function()
match_content(rule)
end,
Expand Down

0 comments on commit 99cdd89

Please sign in to comment.