Class: OpenC3::PypiUrl
Constant Summary collapse
- DEFAULT =
'https://pypi.org/simple'
Class Method Summary collapse
-
.validate(pypi_url) ⇒ String
Validate that a resolved pypi_url is an http(s) URL before it is handed to pip.
Class Method Details
.validate(pypi_url) ⇒ String
Validate that a resolved pypi_url is an http(s) URL before it is handed to pip. The value can come from a user-writable setting or ENV, so a malformed or non-http value is rejected and replaced with the default rather than passed through to pip.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/openc3/utilities/pypi_url.rb', line 28 def self.validate(pypi_url) uri = URI.parse(pypi_url) unless uri.is_a?(URI::HTTP) && !uri.host.to_s.empty? raise URI::InvalidURIError, "not an http(s) URL" end pypi_url rescue URI::InvalidURIError => e Logger.error("Invalid pypi_url '#{pypi_url}' (#{e.}); falling back to #{DEFAULT}") DEFAULT end |