mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
Merge pull request #4089 from mirskiy/github_url_regex_bug
Fix github url regex. Add period for repo
This commit is contained in:
commit
fb0993e0f2
2 changed files with 12 additions and 2 deletions
|
@ -65,8 +65,8 @@ module Fetchers
|
|||
# https://bitbucket.org/username/repo/commits/95ce1f83d5bbe9eec34c5973f6894617e8d6d8cc is transformed to
|
||||
# https://bitbucket.org/username/repo/get/95ce1f83d5bbe9eec34c5973f6894617e8d6d8cc.tar.gz
|
||||
|
||||
GITHUB_URL_REGEX = %r{^https?://(www\.)?github\.com/(?<user>[\w-]+)/(?<repo>[\w-]+)(\.git)?(/)?$}
|
||||
GITHUB_URL_WITH_TREE_REGEX = %r{^https?://(www\.)?github\.com/(?<user>[\w-]+)/(?<repo>[\w-]+)/tree/(?<commit>[\w\.]+)(/)?$}
|
||||
GITHUB_URL_REGEX = %r{^https?://(www\.)?github\.com/(?<user>[\w-]+)/(?<repo>[\w.-]+?)(\.git)?(/)?$}
|
||||
GITHUB_URL_WITH_TREE_REGEX = %r{^https?://(www\.)?github\.com/(?<user>[\w-]+)/(?<repo>[\w.-]+)/tree/(?<commit>[\w\.]+)(/)?$}
|
||||
BITBUCKET_URL_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?<user>[\w-]+)/(?<repo>[\w-]+)(\.git)?(/)?$}
|
||||
BITBUCKET_URL_BRANCH_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?<user>[\w-]+)/(?<repo>[\w-]+)/branch/(?<branch>[\w\.]+)(/)?$}
|
||||
BITBUCKET_URL_COMMIT_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?<user>[\w-]+)/(?<repo>[\w-]+)/commits/(?<commit>[\w\.]+)(/)?$}
|
||||
|
|
|
@ -78,6 +78,16 @@ describe Fetchers::Url do
|
|||
end
|
||||
end
|
||||
|
||||
it "resolves a github url with dot" do
|
||||
expect_url_transform do
|
||||
github = 'https://github.com/mitre/aws-rds-oracle-mysql-ee-5.7-cis-baseline'
|
||||
res = Fetchers::Url.resolve(github)
|
||||
res.expects(:open).returns(mock_open)
|
||||
_(res).wont_be_nil
|
||||
_(res.resolved_source).must_equal({url: 'https://github.com/mitre/aws-rds-oracle-mysql-ee-5.7-cis-baseline/archive/master.tar.gz', sha256: expected_shasum})
|
||||
end
|
||||
end
|
||||
|
||||
it "resolves a github branch url" do
|
||||
expect_url_transform do
|
||||
github = 'https://github.com/hardening-io/tests-os-hardening/tree/2.0'
|
||||
|
|
Loading…
Reference in a new issue