mirror of
https://github.com/dense-analysis/ale
synced 2024-12-18 04:15:39 +00:00
#1149 Fix conversion from URIs to filenames on Windows
This commit is contained in:
parent
e71d831119
commit
cf599f4470
@ -185,5 +185,12 @@ function! ale#path#FromURI(uri) abort
|
|||||||
let l:i = len('file://')
|
let l:i = len('file://')
|
||||||
let l:encoded_path = a:uri[: l:i - 1] is# 'file://' ? a:uri[l:i :] : a:uri
|
let l:encoded_path = a:uri[: l:i - 1] is# 'file://' ? a:uri[l:i :] : a:uri
|
||||||
|
|
||||||
return ale#uri#Decode(l:encoded_path)
|
let l:path = ale#uri#Decode(l:encoded_path)
|
||||||
|
|
||||||
|
" If the path is like /C:/foo/bar, it should be C:\foo\bar instead.
|
||||||
|
if l:path =~# '^/[a-zA-Z]:'
|
||||||
|
let l:path = substitute(l:path[1:], '/', '\\', 'g')
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:path
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -2,6 +2,9 @@ Execute(ale#path#ToURI should work for Windows paths):
|
|||||||
AssertEqual 'file:///C:/foo/bar/baz.tst', ale#path#ToURI('C:\foo\bar\baz.tst')
|
AssertEqual 'file:///C:/foo/bar/baz.tst', ale#path#ToURI('C:\foo\bar\baz.tst')
|
||||||
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo\bar\baz.tst')
|
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo\bar\baz.tst')
|
||||||
|
|
||||||
|
Execute(ale#path#FromURI should work for Windows paths):
|
||||||
|
AssertEqual 'C:\foo\bar\baz.tst', ale#path#FromURI('file:///C:/foo/bar/baz.tst')
|
||||||
|
|
||||||
Execute(ale#path#ToURI should work for Unix paths):
|
Execute(ale#path#ToURI should work for Unix paths):
|
||||||
AssertEqual 'file:///foo/bar/baz.tst', ale#path#ToURI('/foo/bar/baz.tst')
|
AssertEqual 'file:///foo/bar/baz.tst', ale#path#ToURI('/foo/bar/baz.tst')
|
||||||
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo/bar/baz.tst')
|
AssertEqual 'foo/bar/baz.tst', ale#path#ToURI('foo/bar/baz.tst')
|
||||||
|
Loading…
Reference in New Issue
Block a user