Skip to content

Commit 7d929e5

Browse files
author
Brian Shore
committed
Anchor repo extraction regex patterns
Update the patterns to anchor at the end of the string while retaining the optional `.git` suffix in the repo URL.
1 parent e1ecf55 commit 7d929e5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

plugin/github-link.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ function! s:execute_with_commit(commit, startline, endline)
5050
endfunction
5151

5252
function! s:get_repo_url_from_git_protocol(uri)
53-
let s:matches = matchlist(a:uri, '^git@\(.*\):\(.*\)\(.git\)\=')
53+
let s:matches = matchlist(a:uri, '^git@\(.*\):\(.\+\)\(.git\)\=$')
5454
return "https://" . s:matches[1] .'/' . s:matches[2]
5555
endfunction
5656

5757
function! s:get_repo_url_from_ssh_protocol(uri)
58-
let s:matches = matchlist(a:uri, '^ssh:\/\/git@\(.\{-\}\)\/\(.*\)\(.git\)\=')
58+
let s:matches = matchlist(a:uri, '^ssh:\/\/git@\(.\{-\}\)\/\(.\+\)\(.git\)\=$')
5959
return "https://" . s:matches[1] .'/' . s:matches[2]
6060
endfunction
6161

6262
function! s:get_repo_url_from_https_protocol(uri)
63-
let s:matches = matchlist(a:uri, '^\(.*\)\(.git\)\=')
63+
let s:matches = matchlist(a:uri, '^\(https:\/\/.\+\)\(.git\)\=$')
6464
return s:matches[1]
6565
endfunction

0 commit comments

Comments
 (0)