From 67ea571659f31f2ac2253789fabb6b1a30661508 Mon Sep 17 00:00:00 2001 From: w0rp Date: Wed, 13 Mar 2019 15:54:09 +0000 Subject: Handle pipes in Windows drive letters for URIs --- autoload/ale/path.vim | 3 ++- test/test_path_uri.vader | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim index ca3afc52..25193ddb 100644 --- a/autoload/ale/path.vim +++ b/autoload/ale/path.vim @@ -206,8 +206,9 @@ function! ale#path#FromURI(uri) abort endif " If the path is like /C:/foo/bar, it should be C:\foo\bar instead. - if l:encoded_path =~# '^/[a-zA-Z]:' + if l:encoded_path =~# '^/[a-zA-Z][:|]' let l:encoded_path = substitute(l:encoded_path[1:], '/', '\\', 'g') + let l:encoded_path = l:encoded_path[0] . ':' . l:encoded_path[2:] endif return ale#uri#Decode(l:encoded_path) diff --git a/test/test_path_uri.vader b/test/test_path_uri.vader index 504aba77..b49d7a5a 100644 --- a/test/test_path_uri.vader +++ b/test/test_path_uri.vader @@ -16,6 +16,14 @@ Execute(ale#path#FromURI should work for Windows paths): AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:///C:/foo/bar/baz.tst') AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:/C:/foo/bar/baz.tst') +Execute(ale#path#FromURI parse Windows paths with a pipe): + AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:///C|/foo/bar/baz.tst') + AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:/C|/foo/bar/baz.tst') + AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromURI('file:///c|/foo/bar/baz.tst') + AssertEqual 'c:\foo\bar\baz.tst', ale#path#FromURI('file:/c|/foo/bar/baz.tst') + AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:///C|/foo/bar/baz.tst') + AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('FILE:/C|/foo/bar/baz.tst') + Execute(ale#path#FromURI should handle encoded paths that look like drive letters): AssertEqual '/C:/foo/bar/baz.tst', ale#path#FromURI('file:///C%3A/foo/bar/baz.tst') -- cgit v1.2.3