local config = require('muwiki.config') local M = {} function M.execute(handler, url) if type(handler.cmd) == 'function' then handler.cmd(url) else vim.system({ handler.cmd, url }, { detach = true }) end end function M.matches(handler, url) local pattern = handler.pattern if pattern == nil then return true end if type(pattern) == 'string' then return url:match(pattern) ~= nil end for _, p in ipairs(pattern) do if url:match(p) then return true end end return false end function M.get_matching(url) local matching = {} for _, handler in ipairs(config.options.external_handlers) do if M.matches(handler, url) then table.insert(matching, handler) end end return matching end return M