Skip to content

Commit

Permalink
Merge pull request #36 from miduddin/dev
Browse files Browse the repository at this point in the history
fix opening urls with subgroup
  • Loading branch information
Almo7aya authored Dec 2, 2024
2 parents cddd087 + c4deda1 commit 9131016
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lua/openingh/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ end
-- returns a table with the host, user/org and the reponame given a github remote url
-- nil is returned when the url cannot be parsed
function M.parse_gh_remote(url)
-- 3 capture groups for host, org/user and repo. whitespace is trimmed
-- when cloning with http://, gh redirects to https://, but remote stays http
local http = { string.find(url, "https?://([^/]*)/([^/]*)/([^%s/]*)") }
-- ssh url can be of type:
-- url can be of type:
-- http://github.com/user_or_org/reponame
-- https://github.com/user_or_org/reponame
-- https://gitlab.com/user_or_org/group/reponame
-- [email protected]:user_or_org/reponame.git
-- ssh://[email protected]/user_or_org/reponame.git
-- ssh://[email protected]/org/reponame.git
-- .* is used for ssh:// since lua matching doesn't support optional groups, only chars
local ssh = { string.find(url, ".*@(.*)[:/]([^/]*)/([^%s/]*)") }

local matches = http[1] == nil and ssh or http
local matches = { string.find(url, "^.+[@/]([%w%.]+%.%w+)[/:](.+)/(%S+)") }
if matches[1] == nil then
return nil
end
Expand Down

0 comments on commit 9131016

Please sign in to comment.