Module: Chef::Mixin::Uris
- Included in:
- Provider::Package::Cab, Provider::Package::Msu, Provider::Package::Windows, Provider::RemoteFile::Content, Resource::CabPackage, Resource::MsuPackage, Resource::RemoteFile, Resource::WindowsPackage
- Defined in:
- lib/chef/mixin/uris.rb
Instance Method Summary collapse
- #as_uri(source) ⇒ Object
-
#uri_scheme?(source) ⇒ Boolean
uri_scheme? returns true if the string starts with scheme:// For example, it will match http://foo.bar.com.
Instance Method Details
#as_uri(source) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/chef/mixin/uris.rb', line 35 def as_uri(source) URI.parse(source) rescue URI::InvalidURIError Chef::Log.warn("#{source} was an invalid URI. Trying to escape invalid characters") URI.parse(Addressable::URI.encode(source)) end |
#uri_scheme?(source) ⇒ Boolean
uri_scheme? returns true if the string starts with scheme:// For example, it will match http://foo.bar.com
30 31 32 33 |
# File 'lib/chef/mixin/uris.rb', line 30 def uri_scheme?(source) # From open-uri !!(%r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ source) end |