-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from miduddin/dev
fix opening urls with subgroup
- Loading branch information
Showing
1 changed file
with
5 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|