diff options
| author | moxie <moxie@3kgcat.fi> | 2026-03-15 09:54:31 +0200 |
|---|---|---|
| committer | moxie <moxie@3kgcat.fi> | 2026-03-15 10:05:20 +0200 |
| commit | de2df63dcbe44f07dc994e29d7d400c49c811080 (patch) | |
| tree | 10ae2c8eee90c661792e71aa5bd35cd26f5407d4 /lua/muwiki/paths.lua | |
| parent | 49c1e9d1fc3d6bf8748756a8543d8c1b7287940f (diff) | |
refactor: simplify codebase and fix FileType autocommands
Diffstat (limited to 'lua/muwiki/paths.lua')
| -rw-r--r-- | lua/muwiki/paths.lua | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/lua/muwiki/paths.lua b/lua/muwiki/paths.lua deleted file mode 100644 index c2f8fdb..0000000 --- a/lua/muwiki/paths.lua +++ /dev/null @@ -1,43 +0,0 @@ -local M = {} - -function M.get_path_type(path) - if path:sub(1, 1) == '/' then - return 'absolute' - elseif path:sub(1, 1) == '~' then - return 'home' - else - return 'relative' - end -end - -function M.resolve(filepath, current_file) - local path_type = M.get_path_type(filepath) - - if path_type == 'relative' then - local base = current_file and vim.fs.dirname(current_file) - or vim.fs.dirname(vim.api.nvim_buf_get_name(0)) - filepath = vim.fs.joinpath(base, filepath) - end - - return vim.fs.normalize(filepath) -end - -function M.strip_file_protocol(url) - return url:gsub('^file://', '') -end - -local ALLOWED_SCHEMES = { - http = true, - https = true, - file = true, -} - -function M.validate_url_scheme(url) - local scheme = url:match('^([a-zA-Z]+)://') - if scheme and not ALLOWED_SCHEMES[scheme:lower()] then - return false, string.format('URL scheme not allowed: %s', scheme) - end - return true, nil -end - -return M |
