Skip to content
Snippets Groups Projects
Unverified Commit cb38fe6e authored by Rylan Polster's avatar Rylan Polster Committed by GitHub
Browse files

Merge pull request #9413 from Rylan12/pypi-fix

utils/pypi: return nil for non-pypi-packages from url
parents 01fb30c0 22a3025f
No related branches found
No related tags found
No related merge requests found
......@@ -172,5 +172,13 @@ describe PyPI do
it "updates url to new version" do
expect(described_class.update_pypi_url(old_package_url, "5.29.0")).to eq package_url
end
it "returns nil for invalid versions" do
expect(described_class.update_pypi_url(old_package_url, "0.0.0")).to eq nil
end
it "returns nil for non-pypi urls" do
expect(described_class.update_pypi_url("https://brew.sh/foo-1.0.tgz", "1.1")).to eq nil
end
end
end
......@@ -110,8 +110,12 @@ module PyPI
def update_pypi_url(url, version)
package = Package.new url, is_url: true
return unless package.valid_pypi_package?
_, url = package.pypi_info(version: version)
url
rescue ArgumentError
nil
end
# Return true if resources were checked (even if no change).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment