diff --git a/common/lib/dependabot/source.rb b/common/lib/dependabot/source.rb index 4e96625b200..f7342f2b898 100644 --- a/common/lib/dependabot/source.rb +++ b/common/lib/dependabot/source.rb @@ -21,8 +21,8 @@ class Source GITLAB_SOURCE = %r{ (?gitlab) (?:\.com)[/:] - (?(?!\.git|/tree|/blob)[\w./-]+?)(?:\.git)? - (?:(?:/tree|/blob)/(?[^/]+)/(?.*)[\#|/].*)?$ + (?[^/]+/(?:(?!\.git)[^/])+((?!/tree|/blob/|/-)/[^/]+)?) + (?:(?:/tree|/blob)/(?[^/]+)/(?.*)[\#|/].*)? }x.freeze BITBUCKET_SOURCE = %r{ diff --git a/common/spec/dependabot/source_spec.rb b/common/spec/dependabot/source_spec.rb index d1c132b0e44..aaed836cc0e 100644 --- a/common/spec/dependabot/source_spec.rb +++ b/common/spec/dependabot/source_spec.rb @@ -256,6 +256,13 @@ its(:directory) { is_expected.to eq("dir") } end + context "with a GitLab changelog link" do + let(:url) { "https://gitlab.com/oauth-xx/oauth2/-/tree/v2.0.9/CHANGELOG.md" } + its(:provider) { is_expected.to eq("gitlab") } + its(:repo) { is_expected.to eq("oauth-xx/oauth2") } + its(:directory) { is_expected.to be_nil } + end + context "with a GitLab subgroup URL" do let(:url) { "https://gitlab.com/org/group/abc/blob/master/dir/readme.md" } its(:provider) { is_expected.to eq("gitlab") }