diff --git a/nuget/lib/dependabot/nuget/metadata_finder.rb b/nuget/lib/dependabot/nuget/metadata_finder.rb index 9af91cfdd14..77c12ce0291 100644 --- a/nuget/lib/dependabot/nuget/metadata_finder.rb +++ b/nuget/lib/dependabot/nuget/metadata_finder.rb @@ -121,21 +121,7 @@ def dependency_nuspec_url source = dependency.requirements. find { |r| r&.fetch(:source) }&.fetch(:source) - if source&.key?(:nuspec_url) - source.fetch(:nuspec_url) || - "https://api.nuget.org/v3-flatcontainer/" \ - "#{dependency.name.downcase}/#{dependency.version}/" \ - "#{dependency.name.downcase}.nuspec" - elsif source&.key?(:nuspec_url) - source.fetch("nuspec_url") || - "https://api.nuget.org/v3-flatcontainer/" \ - "#{dependency.name.downcase}/#{dependency.version}/" \ - "#{dependency.name.downcase}.nuspec" - else - "https://api.nuget.org/v3-flatcontainer/" \ - "#{dependency.name.downcase}/#{dependency.version}/" \ - "#{dependency.name.downcase}.nuspec" - end + return source.fetch(:nuspec_url) if source&.key?(:nuspec_url) end def dependency_source_url diff --git a/nuget/spec/dependabot/nuget/metadata_finder_spec.rb b/nuget/spec/dependabot/nuget/metadata_finder_spec.rb index be64e1211da..0621e857812 100644 --- a/nuget/spec/dependabot/nuget/metadata_finder_spec.rb +++ b/nuget/spec/dependabot/nuget/metadata_finder_spec.rb @@ -59,15 +59,6 @@ ) end - context "with a github link in the nuspec" do - it { is_expected.to eq("https://github.com/dotnet/core-setup") } - - it "caches the call to nuget" do - 2.times { source_url } - expect(WebMock).to have_requested(:get, nuget_url).once - end - end - context "with a source" do let(:source) do { @@ -94,7 +85,7 @@ expect(WebMock).to have_requested(:get, nuget_url).once end - context "that has a source_url" do + context "that has a source_url only" do let(:source) do { type: "nuget_repo", @@ -117,13 +108,7 @@ } end - let(:nuget_url) do - "https://api.nuget.org/v3-flatcontainer/" \ - "microsoft.extensions.dependencymodel/2.1.0/" \ - "microsoft.extensions.dependencymodel.nuspec" - end - - it { is_expected.to eq("https://github.com/dotnet/core-setup") } + it { is_expected.to eq(nil) } end context "with details in the credentials (but no token)" do