From b8f34181e4fd57f76b887b3b4615915e10efb378 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Mon, 25 Aug 2025 16:44:15 +0200 Subject: [PATCH] Remove trailing slash to avoid double slashes I had my remote set to: `https://company.example/some-org/some-repo/` Which is valid, but caused the generated links to have double slashes, which GitLab didn't like, and showed an empty page instead of the file. Changing my remote to: `https://company.example/some-org/some-repo` fixed the issue, but I think it would be better if the plugin handled this case. GitHub suffers from a similar problem --- plugin/github-link.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/github-link.vim b/plugin/github-link.vim index 9dd9bdb..1c24a48 100644 --- a/plugin/github-link.vim +++ b/plugin/github-link.vim @@ -82,7 +82,10 @@ endfunction function! s:trim_git_suffix(str) " strip whitespace such as trailing \r from git command output let s:nospace = substitute(a:str, '[[:space:]]', '', 'g') - return substitute(s:nospace, '\.git$', '', '') + " strip trailing slashes so the URL doesn't end up with a double slash + " (e.g. a remote configured as .../OWNER/REPO/ producing REPO//blob/...) + let s:noslash = substitute(s:nospace, '\/\+$', '', '') + return substitute(s:noslash, '\.git$', '', '') endfunction " copied from tpope/vim-unimpaired