diff options
| author | moxie <moxie@3kgcat.fi> | 2026-03-15 13:21:28 +0200 |
|---|---|---|
| committer | moxie <moxie@3kgcat.fi> | 2026-03-15 13:51:05 +0200 |
| commit | 97cbb42f24ef8836c2d7738e60d67515384c3f7c (patch) | |
| tree | beecfc2935227f30b21201a201ca80eb959ec893 /lua/muwiki/utils.lua | |
| parent | be3794da7602a78aec527750986c05d5bc8bd930 (diff) | |
fix(utils): resolve relative paths correctly
Diffstat (limited to 'lua/muwiki/utils.lua')
| -rw-r--r-- | lua/muwiki/utils.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lua/muwiki/utils.lua b/lua/muwiki/utils.lua index bc6094e..273a466 100644 --- a/lua/muwiki/utils.lua +++ b/lua/muwiki/utils.lua @@ -60,9 +60,11 @@ end function M.resolve(filepath, wiki_root) local path = filepath:gsub('^file://', '') local path_type = path:sub(1, 1) - if path_type ~= '/' and path_type ~= '~' then - local base = wiki_root and vim.fs.dirname(wiki_root) - or vim.fs.dirname(vim.api.nvim_buf_get_name(0)) + if path_type == '.' then + local current_dir = vim.fs.dirname(vim.api.nvim_buf_get_name(0)) + path = vim.fs.joinpath(current_dir, path) + elseif path_type ~= '/' and path_type ~= '~' then + local base = wiki_root or vim.fs.dirname(vim.api.nvim_buf_get_name(0)) path = vim.fs.joinpath(base, path) end return vim.fs.normalize(path) |
