mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
feat(vim.uri): Allow URI schemes other than file: without authority
This commit is contained in:

committed by
Alessandro Pezzoni

parent
82a443e1f3
commit
1dab9357de
@@ -74,7 +74,7 @@ local function uri_from_fname(path)
|
|||||||
return table.concat(uri_parts)
|
return table.concat(uri_parts)
|
||||||
end
|
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
|
--- Get a URI from a bufnr
|
||||||
--@param bufnr (number): Buffer number
|
--@param bufnr (number): Buffer number
|
||||||
|
@@ -140,6 +140,12 @@ describe('URI methods', function()
|
|||||||
return vim.uri_to_fname('JDT://content/%5C/')
|
return vim.uri_to_fname('JDT://content/%5C/')
|
||||||
]])
|
]])
|
||||||
end)
|
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)
|
end)
|
||||||
|
|
||||||
describe('decode URI without scheme', function()
|
describe('decode URI without scheme', function()
|
||||||
@@ -161,5 +167,14 @@ describe('URI methods', function()
|
|||||||
]], uri)
|
]], uri)
|
||||||
eq(uri, exec_lua(test_case))
|
eq(uri, exec_lua(test_case))
|
||||||
end)
|
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)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user