Module: Chef::Mixin::Uris
- Included in:
- Provider::Package::Cab, Provider::Package::Msu, Provider::Package::Windows, Provider::RemoteFile::Content, Resource::CabPackage, Resource::MsuPackage, Resource::PowershellPackage, 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 foo.bar.com.
Instance Method Details
#as_uri(source) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/chef/mixin/uris.rb', line 33 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 foo.bar.com
28 29 30 31 |
# File 'lib/chef/mixin/uris.rb', line 28 def uri_scheme?(source) # From open-uri !!(%r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ source) end |