Skip to content

Commit

Permalink
Fix ruby 3 bug for the download method
Browse files Browse the repository at this point in the history
the `URI#unescape` method does not exists anymore on ruby 3.
I used the `#decode_www_form_component` method instead to replace %20
like characters.
  • Loading branch information
benjamin-ltr committed May 15, 2024
1 parent 6e5d24a commit 1b1e6cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ilovepdf/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def download_file
content_disposition = response.headers[:content_disposition]

if match_data = /filename\*\=utf-8\'\'([\W\w]+)/.match(content_disposition)
filename = URI.unescape(match_data[1].gsub('"', ''))
filename = URI.decode_www_form_component(match_data[1].gsub('"', ''))
else
match_data = / .*filename=\"([\W\w]+)\"/.match(content_disposition)
filename = match_data[1].gsub('"', '')
Expand Down

0 comments on commit 1b1e6cb

Please sign in to comment.