Handle pipes in Windows drive letters for URIs

This commit is contained in:
w0rp 2019-03-13 15:54:09 +00:00
parent 5f03bae41c
commit 67ea571659
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 10 additions and 1 deletions

View File

@ -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)

View File

@ -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')