aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Payne <tom@tompayne.dev>2021-07-02 15:27:04 +0100
committerAlessandro Pezzoni <alessandro.pezzoni@runbox.com>2021-07-10 18:27:37 +0100
commit1dab9357de586b08431175f19a1b44bb294866d6 (patch)
treef2328f228f882c2a118a64e5bdea3b07711337f8
parent82a443e1f3fa3dd187849777f18d3a77c0a522df (diff)
downloadrneovim-1dab9357de586b08431175f19a1b44bb294866d6.tar.gz
rneovim-1dab9357de586b08431175f19a1b44bb294866d6.tar.bz2
rneovim-1dab9357de586b08431175f19a1b44bb294866d6.zip
feat(vim.uri): Allow URI schemes other than file: without authority
-rw-r--r--runtime/lua/vim/uri.lua2
-rw-r--r--test/functional/lua/uri_spec.lua15
2 files changed, 16 insertions, 1 deletions
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua
index b7805e0cae..82c9a31464 100644
--- a/runtime/lua/vim/uri.lua
+++ b/runtime/lua/vim/uri.lua
@@ -74,7 +74,7 @@ local function uri_from_fname(path)
return table.concat(uri_parts)
end
-local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):/+.*'
+local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*'
--- Get a URI from a bufnr
--@param bufnr (number): Buffer number
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua
index 7d7dae7ed3..052a8a1ecd 100644
--- a/test/functional/lua/uri_spec.lua
+++ b/test/functional/lua/uri_spec.lua
@@ -140,6 +140,12 @@ describe('URI methods', function()
return vim.uri_to_fname('JDT://content/%5C/')
]])
end)
+
+ it('uri_to_fname returns non-file scheme URI without authority unchanged', function()
+ eq('zipfile:/path/to/archive.zip%3A%3Afilename.txt', exec_lua [[
+ return vim.uri_to_fname('zipfile:/path/to/archive.zip%3A%3Afilename.txt')
+ ]])
+ end)
end)
describe('decode URI without scheme', function()
@@ -161,5 +167,14 @@ describe('URI methods', function()
]], uri)
eq(uri, exec_lua(test_case))
end)
+
+ it('uri_to_bufnr & uri_from_bufnr returns original uri for non-file uris without authority', function()
+ local uri = 'zipfile:/path/to/archive.zip%3A%3Afilename.txt'
+ local test_case = string.format([[
+ local uri = '%s'
+ return vim.uri_from_bufnr(vim.uri_to_bufnr(uri))
+ ]], uri)
+ eq(uri, exec_lua(test_case))
+ end)
end)
end)