From 945e7aa6158c5ae707fb7962d5e431f2faa8cd4c Mon Sep 17 00:00:00 2001 From: Artem Vavilov Date: Sat, 3 Feb 2024 17:22:20 +0200 Subject: [PATCH] feat: Return the full API response if the `destination` param is not passed Issue: #66 --- lib/crowdin-api/core/send_request.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/crowdin-api/core/send_request.rb b/lib/crowdin-api/core/send_request.rb index 4a91e2b..f91287d 100644 --- a/lib/crowdin-api/core/send_request.rb +++ b/lib/crowdin-api/core/send_request.rb @@ -44,7 +44,7 @@ def parse_response(response) end def fetch_response_data(doc) - if doc['data'].is_a?(Hash) && doc['data']['url'] && doc['data']['url'].include?('response-content-disposition') + if @file_destination && doc['data'].is_a?(Hash) && doc['data']['url'] download_file(doc['data']['url']) else doc @@ -53,8 +53,7 @@ def fetch_response_data(doc) def download_file(url) download = URI.parse(url).open - destination = @file_destination || download.meta['content-disposition'] - .match(/filename=("?)(.+)\1/)[2] + destination = @file_destination IO.copy_stream(download, destination)