Handle regex not finding anything

This commit is contained in:
Danny Weinberg 2019-02-03 10:52:09 -08:00
parent b0124c4fb0
commit 6db1b0abd8

View File

@ -60,7 +60,7 @@ def curl_download(*args, to: nil, **options)
supports_partial_download = http_status.to_i == 206 # Partial Content
if supports_partial_download &&
destination.exist? &&
destination.size == %r{^.*Content-Range: bytes \d+-\d+/(\d+)\r\n.*$}m.match(headers)[1].to_i
destination.size == %r{^.*Content-Range: bytes \d+-\d+/(\d+)\r\n.*$}m.match(headers)&.[](1)&.to_i
return # We've already downloaded all the bytes
end