summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Timberman <joshua@opscode.com>2013-04-10 13:12:11 -0700
committerJoshua Timberman <joshua@opscode.com>2013-04-10 13:12:11 -0700
commit20997cecfd232db9ed5b29a0e6f637239599d0df (patch)
treee150dceb631bece589cec26a12ad6b1812cc1aec
parentd90c65efe9d3bfe1cd0a1d005d78c1c53d24fe87 (diff)
parentcbeb613d362eb753c4eb622d7f224c3a20f48f84 (diff)
downloadmixlib-shellout-20997cecfd232db9ed5b29a0e6f637239599d0df.tar.gz
Merge pull request #32 from opscode-cookbooks/jtimberman/COOK-2729
[COOK-2729] - use stdlib URI class
-rw-r--r--libraries/helper.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/libraries/helper.rb b/libraries/helper.rb
index 0cf9ddd..f8ac89d 100644
--- a/libraries/helper.rb
+++ b/libraries/helper.rb
@@ -17,6 +17,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+require 'uri'
module Windows
module Helper
@@ -64,8 +65,9 @@ module Windows
def cached_file(source, checksum=nil, windows_path=true)
@installer_file_path ||= begin
- if(source =~ /^(https?:\/\/)(.*\/)(.*)$/)
- cache_file_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(source)}"
+ if ::URI.parse(source).absolute?
+ uri = ::URI.parse(::URI.unescape(source))
+ cache_file_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(uri.path)}"
Chef::Log.debug("Caching a copy of file #{source} at #{cache_file_path}")
r = Chef::Resource::RemoteFile.new(cache_file_path, run_context)
r.source(source)