diff --git a/git-open b/git-open index 6412b8c..0e04015 100755 --- a/git-open +++ b/git-open @@ -177,7 +177,8 @@ IFS='/' read -r -a pathargs <<<"$urlpath" if (( is_issue )); then # For issues, take the numbers and preprend 'issues/' - providerBranchRef="/issues/${remote_ref//[^0-9]/}" + [[ $remote_ref =~ [0-9]+ ]] + providerBranchRef="/issues/${BASH_REMATCH[0]}" else # Make # and % characters url friendly # github.com/paulirish/git-open/pull/24 diff --git a/test/git-open.bats b/test/git-open.bats index 3de5e9e..1f8d4c3 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -522,6 +522,13 @@ setup() { assert_output "https://git.example.com:7000/XXX/YYY" } +@test "gitlab: issue" { + git remote set-url origin "git@gitlab.example.com:user/repo" + git checkout -B "10-bump-up-to-v2.0" + run ../git-open "--issue" + assert_output "https://gitlab.example.com/user/repo/issues/10" +} + ## ## Visual Studio Team Services ##