diff --git a/git-open b/git-open index bc3d121..01a8827 100755 --- a/git-open +++ b/git-open @@ -241,8 +241,8 @@ openurl="$protocol://$domain/$urlpath" if (( is_commit )); then sha=$(git rev-parse HEAD) openurl="$openurl/commit/$sha" -elif [[ $remote_ref != "master" ]]; then - # simplify URL for master +elif [[ $remote_ref != "master" && $remote_ref != "main" ]]; then + # simplify URL for master and main openurl="$openurl$providerBranchRef" fi diff --git a/test/git-open.bats b/test/git-open.bats index 32c0fe1..ea13561 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -58,6 +58,14 @@ setup() { assert_output "http://example.com/example" } +@test "url: simplification" { + git config --local url.http://example.com/.insteadOf ex: + git remote set-url origin ex:example.git + git checkout -B main + run ../git-open + assert_output "http://example.com/example" +} + ## ## GitHub ##