Skip to content

Commit d994553

Browse files
committed
fix: make sure realpath and path's ends are matched
e.g. /path/to/me ../to/me /path/to/me/ ../to/me/
1 parent 99d8313 commit d994553

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lua/orgmode/org/hyperlinks/url.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function Url:_parse_path_type()
252252
or (first_char == '~' and self.path:sub(2, 2) == '/')
253253
then
254254
self.path_type = 'file'
255-
self.realpath = fs.substitute_path(self.path) or self.path
255+
self.realpath = fs.get_real_path(self.path, true) or self.path
256256
return
257257
end
258258

lua/orgmode/utils/fs.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function M.substitute_path(path_str)
2121
end
2222

2323
---@param filepath string
24-
function M.get_real_path(filepath)
24+
function M.get_real_path(filepath, match)
2525
if not filepath then
2626
return false
2727
end
@@ -30,6 +30,12 @@ function M.get_real_path(filepath)
3030
return false
3131
end
3232
local real = vim.loop.fs_realpath(substituted)
33+
if match then
34+
-- if path ends with / , real needs too
35+
if filepath:sub(-1, -1) == '/' then
36+
real = real .. '/'
37+
end
38+
end
3339
return real or false
3440
end
3541

0 commit comments

Comments
 (0)