mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2026-06-09 15:37:30 +02:00
Fix index
This commit is contained in:
@@ -6,7 +6,7 @@ function! s:decode_uri(uri) abort
|
||||
let l:ret = a:uri
|
||||
let l:pos = stridx(l:ret, '?')
|
||||
if l:pos != -1
|
||||
let [l:lhs, l:rhs] = [l:ret[: l:pos], l:ret[l:pos :]]
|
||||
let [l:lhs, l:rhs] = [l:ret[: l:pos], l:ret[l:pos+1 :]]
|
||||
let l:ret = l:lhs . substitute(l:rhs, '+', ' ', 'g')
|
||||
endif
|
||||
return substitute(l:ret, '%\(\x\x\)', '\=printf("%c", str2nr(submatch(1), 16))', 'g')
|
||||
|
||||
@@ -8,4 +8,39 @@ Describe lsp#utils
|
||||
End
|
||||
End
|
||||
|
||||
Describe lsp#utils#uri_to_path
|
||||
It should return path from uri (Windows)
|
||||
if !has('win32')
|
||||
Skip This tests is not for UNIX
|
||||
endif
|
||||
let tests = [
|
||||
\ {'uri': 'file:///C:/path/to/the/file.txt', 'path': 'C:\path\to\the\file.txt'},
|
||||
\ {'uri': 'file:///C:/path/to/the/file+name.txt', 'path': 'C:\path\to\the\file+name.txt'},
|
||||
\ {'uri': 'file:///C:/path/to/the/file%2Bname.txt', 'path': 'C:\path\to\the\file+name.txt'},
|
||||
\ {'uri': 'file:///C:/path/to/the/file%20name.txt', 'path': 'C:\path\to\the\file name.txt'},
|
||||
\ {'uri': 'file:///C:/path+name?query=your+value', 'path': 'C:\path+name?query=your value'},
|
||||
\]
|
||||
for test in tests
|
||||
let path = lsp#utils#uri_to_path(test.uri)
|
||||
Assert Equals(path, test.path)
|
||||
endfor
|
||||
End
|
||||
|
||||
It should return path from uri (UNIX)
|
||||
if has('win32')
|
||||
Skip This tests is not for Windows
|
||||
endif
|
||||
let tests = [
|
||||
\ {'uri': 'file:///path/to/the/file.txt', 'path': '/path/to/the/file.txt'},
|
||||
\ {'uri': 'file:///path/to/the/file+name.txt', 'path': '/path/to/the/file+name.txt'},
|
||||
\ {'uri': 'file:///path/to/the/file%2Bname.txt', 'path': '/path/to/the/file+name.txt'},
|
||||
\ {'uri': 'file:///path/to/the/file%20name.txt', 'path': '/path/to/the/file name.txt'},
|
||||
\ {'uri': 'file:///path+name?query=your+value', 'path': '/path+name?query=your value'},
|
||||
\]
|
||||
for test in tests
|
||||
let path = lsp#utils#uri_to_path(test.uri)
|
||||
Assert Equals(path, test.path)
|
||||
endfor
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Reference in New Issue
Block a user