mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 04:53:45 -05:00
Use URL encoding for Fugitive URLs
This makes them conform to whatever the RFC for URLs is.
This commit is contained in:
@@ -88,6 +88,18 @@ function! s:UrlEncode(str) abort
|
|||||||
return substitute(a:str, '[%#?&;+\<> [:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g')
|
return substitute(a:str, '[%#?&;+\<> [:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:PathUrlEncode(str) abort
|
||||||
|
return substitute(a:str, '[%#?[:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:PathJoin(prefix, str) abort
|
||||||
|
if a:prefix =~# '://'
|
||||||
|
return a:prefix . s:PathUrlEncode(a:str)
|
||||||
|
else
|
||||||
|
return a:prefix . a:str
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:throw(string) abort
|
function! s:throw(string) abort
|
||||||
throw 'fugitive: '.a:string
|
throw 'fugitive: '.a:string
|
||||||
endfunction
|
endfunction
|
||||||
@@ -553,18 +565,14 @@ endfunction
|
|||||||
if exists('+shellslash')
|
if exists('+shellslash')
|
||||||
function! s:DirUrlPrefix(dir) abort
|
function! s:DirUrlPrefix(dir) abort
|
||||||
let gd = s:GitDir(a:dir)
|
let gd = s:GitDir(a:dir)
|
||||||
return 'fugitive://' . (gd =~# '^[^/]' ? '/' : '') . gd . '//'
|
return 'fugitive://' . (gd =~# '^[^/]' ? '/' : '') . s:PathUrlEncode(gd) . '//'
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:DirUrlPrefix(dir) abort
|
function! s:DirUrlPrefix(dir) abort
|
||||||
return 'fugitive://' . s:GitDir(a:dir) . '//'
|
return 'fugitive://' . s:PathUrlEncode(s:GitDir(a:dir)) . '//'
|
||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:PathJoin(prefix, str) abort
|
|
||||||
return a:prefix . a:str
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:Tree(...) abort
|
function! s:Tree(...) abort
|
||||||
return a:0 ? FugitiveWorkTree(a:1) : FugitiveWorkTree()
|
return a:0 ? FugitiveWorkTree(a:1) : FugitiveWorkTree()
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1638,7 +1646,7 @@ function! s:DirCommitFile(path) abort
|
|||||||
if empty(vals)
|
if empty(vals)
|
||||||
return ['', '', '']
|
return ['', '', '']
|
||||||
endif
|
endif
|
||||||
return [s:Dir(vals[1])] + (empty(vals[2]) ? ['', '/.git/index'] : vals[2:3])
|
return [s:Dir(fugitive#UrlDecode(vals[1])), vals[2], empty(vals[2]) ? '/.git/index' : fugitive#UrlDecode(vals[3])]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:DirRev(url) abort
|
function! s:DirRev(url) abort
|
||||||
|
|||||||
Reference in New Issue
Block a user