Fix index

This commit is contained in:
Yasuhiro Matsumoto
2019-01-29 09:03:25 +09:00
parent 84e80a5e99
commit 52e1b05f29
2 changed files with 36 additions and 1 deletions
+1 -1
View File
@@ -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')
+35
View File
@@ -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