fix(path): path_is_url returns false for "foo:/" #19797

Problem:
path_to_url() returns false for single-slash URIs ("foo:/" vs "foo://").
This is not compliant with the URI spec. https://url.spec.whatwg.org/#url-representation
LSP in particular allows single-slash URIs.

Solution:
Relax path_to_url() to accept single-slash URIs. This is not fully
compliant (only ":" is required by the spec), but it is hopefully good
enough without causing false-positives in typical text files.

ref https://url.spec.whatwg.org/#windows-drive-letter
ref https://github.com/neovim/neovim/pull/19773
ref https://github.com/neovim/neovim/pull/19773#issuecomment-1214763769
This commit is contained in:
sigmaSd
2022-08-24 07:38:06 +01:00
committed by GitHub
parent 9a100ee169
commit a4e4609d62
3 changed files with 27 additions and 5 deletions

View File

@@ -640,6 +640,10 @@ describe('path.c', function()
eq(2, path_with_url([[test-abc:\\xyz\foo\b3]]))
eq(0, path_with_url([[-test://xyz/foo/b4]]))
eq(0, path_with_url([[test-://xyz/foo/b5]]))
eq(1, path_with_url([[test-C:/xyz/foo/b5]]))
eq(1, path_with_url([[test-custom:/xyz/foo/b5]]))
eq(0, path_with_url([[c:/xyz/foo/b5]]))
eq(0, path_with_url([[C:/xyz/foo/b5]]))
end)
end)
end)