Handle trailing slash in enterprise URL

This commit is contained in:
Tim Pope
2020-04-08 07:20:10 -04:00
parent 5130596a65
commit 0eaa213f01

View File

@@ -26,9 +26,8 @@ endfunction
function! rhubarb#HomepageForUrl(url) abort
let domain_pattern = 'github\.com'
let domains = get(g:, 'github_enterprise_urls', get(g:, 'fugitive_github_domains', []))
call map(copy(domains), 'substitute(v:val, "/$", "", "")')
for domain in domains
let domain_pattern .= '\|' . escape(split(domain, '://')[-1], '.')
let domain_pattern .= '\|' . escape(split(substitute(domain, '/$', '', ''), '://')[-1], '.')
endfor
let base = matchstr(a:url, '^\%(https\=://\%([^@/:]*@\)\=\|git://\|git@\|ssh://git@\)\=\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=/\=$')
if index(domains, 'http://' . matchstr(base, '^[^:/]*')) >= 0