Remove leading slash when parsing scpremote:/~user

This commit is contained in:
Tim Pope
2021-10-12 13:55:32 -04:00
parent a4c6fb74ee
commit ca61174e9d

View File

@@ -1253,19 +1253,23 @@ endfunction
function! s:UrlParse(url) abort function! s:UrlParse(url) abort
let scp_authority = matchstr(a:url, '^[^:/]\+\ze:\%(//\)\@!') let scp_authority = matchstr(a:url, '^[^:/]\+\ze:\%(//\)\@!')
if len(scp_authority) && !(has('win32') && scp_authority =~# '^\a:[\/]') if len(scp_authority) && !(has('win32') && scp_authority =~# '^\a:[\/]')
return {'scheme': 'ssh', 'authority': scp_authority, let url = {'scheme': 'ssh', 'authority': scp_authority,
\ 'path': strpart(a:url, len(scp_authority) + 1)} \ 'path': strpart(a:url, len(scp_authority) + 1)}
elseif empty(a:url)
let url = {'scheme': '', 'authority': '', 'path': ''}
else
let match = matchlist(a:url, '^\([[:alnum:].+-]\+\)://\([^/]*\)\(/.*\)\=\%(#\|$\)')
if empty(match)
let url = {'scheme': 'file', 'authority': '', 'path': a:url}
else
let url = {'scheme': match[1], 'authority': match[2]}
let url.path = empty(match[3]) ? '/' : match[3]
endif
endif endif
let match = matchlist(a:url, '^\([[:alnum:].+-]\+\)://\([^/]*\)\(/.*\)\=\%(#\|$\)') if (url.scheme ==# 'ssh' || url.scheme ==# 'git') && url.path[0:1] ==# '/~'
if empty(match) let url.path = strpart(url.path, 1)
return {'scheme': 'file', 'authority': '', 'path': a:url}
endif endif
let remote = {'scheme': match[1], 'authority': match[2]} return url
let remote.path = empty(match[3]) ? '/' : match[3]
if (remote.scheme ==# 'ssh' || remote.scheme ==# 'git') && remote.path[0:1] ==# '/~'
let remote.path = strpart(remote.path, 1)
endif
return remote
endfunction endfunction
function! s:ResolveRemote(url) abort function! s:ResolveRemote(url) abort