diff options
Diffstat (limited to 'runtime/lua/vim/uri.lua')
-rw-r--r-- | runtime/lua/vim/uri.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index b4e4098b91..8b6f1a61ee 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -15,7 +15,7 @@ local PATTERNS = { rfc2396 = "^A-Za-z0-9%-_.!~*'()", -- RFC 2732 -- https://tools.ietf.org/html/rfc2732 - rfc2732 = "^A-Za-z0-9%-_.!~*'()[]", + rfc2732 = "^A-Za-z0-9%-_.!~*'()%[%]", -- RFC 3986 -- https://tools.ietf.org/html/rfc3986#section-2.2 rfc3986 = "^A-Za-z0-9%-._~!$&'()*+,;=:@/", @@ -60,9 +60,10 @@ end ---@param path string Path to file ---@return string URI function M.uri_from_fname(path) - local volume_path, fname = path:match('^([a-zA-Z]:)(.*)') ---@type string? + local volume_path, fname = path:match('^([a-zA-Z]:)(.*)') ---@type string?, string? local is_windows = volume_path ~= nil if is_windows then + assert(fname) path = volume_path .. M.uri_encode(fname:gsub('\\', '/')) else path = M.uri_encode(path) @@ -111,7 +112,7 @@ function M.uri_to_fname(uri) uri = M.uri_decode(uri) --TODO improve this. if is_windows_file_uri(uri) then - uri = uri:gsub('^file:/+', ''):gsub('/', '\\') + uri = uri:gsub('^file:/+', ''):gsub('/', '\\') --- @type string else uri = uri:gsub('^file:/+', '/') ---@type string end |