From cd0bbd399f696953b08891cd3ab328f9c94c3b89 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. --- plugin/github-link.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/github-link.vim b/plugin/github-link.vim index 9dd9bdb..dcedde8 100644 --- a/plugin/github-link.vim +++ b/plugin/github-link.vim @@ -76,7 +76,7 @@ endfunction function! s:get_repo_url_from_https_protocol(uri) let s:matches = matchlist(a:uri, '^https:\/\/\(.*@\)\?\(.*\)$') - return "https://" . s:trim_git_suffix(s:matches[2]) + return "https://" . s:trim_git_suffix(s:trim_trailing_slash(s:matches[2])) endfunction function! s:trim_git_suffix(str) @@ -85,6 +85,10 @@ function! s:trim_git_suffix(str) return substitute(s:nospace, '\.git$', '', '') endfunction +function! s:trim_trailing_slash(str) + return substitute(a:str, '\/$', '', '') +endfunction + " copied from tpope/vim-unimpaired function! s:url_encode(str) abort " iconv trick to convert utf-8 bytes to 8bits indiviual char.