Skip to content

Commit

Permalink
Fix for orgs with dashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Morozzzko committed Sep 25, 2024
1 parent 19c8ab2 commit 047d11f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/git_browse/url_builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ M.build_gitlab_url = function(domain, repo, branch_name, path, url_type)
end

M.build_url = function(remote, current_branch_name, path_in_repo, url_type)
local _, _, domain, repo = string.find(remote, "[htps:/@]+(.*)[/:](%a+/.+)%p.*")
local _, _, domain, repo = string.find(remote, "[htps:/@]+(.*)[/:]([%a-]+/.+)%p.*")

if domain and repo then
if string.find(domain, "github.com") then
Expand Down
7 changes: 7 additions & 0 deletions tests/git_browse/url_builder_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ describe("URL builder", function()
)
end)

it("generates a URL from SSH remote and current branch", function()
assert.are.same(
"https://github.com/Morozzzko-with-suffix/git-browse-nvim/tree/main",
module.build_url("[email protected]:Morozzzko-with-suffix/git-browse-nvim.git", "main", nil, "browse")
)
end)

it("generates a URL from SSH remote and current branch", function()
assert.are.same(
"https://github.com/Morozzzko/git-browse-nvim/tree/main",
Expand Down

0 comments on commit 047d11f

Please sign in to comment.