Skip to content

Commit

Permalink
Merge pull request #134 from ontoportal-lirmm/pl/fix-github-releases-…
Browse files Browse the repository at this point in the history
…download-file

Update the regex of extracting the file name from a dowloaded response header
  • Loading branch information
jvendetti authored Jul 14, 2022
2 parents bd227e2 + 35058f7 commit 9997331
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ontologies_linked_data/utils/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def self.download_file(uri, limit = 10)

file_size = res.read_header["content-length"].to_i
begin
filename = res.read_header["content-disposition"].match(/filename=\"(.*)\"/)[1] if filename.nil?
content_disposition = res.read_header['content-disposition']
filenames = content_disposition.match(/filename=\"(.*)\"/) || content_disposition.match(/filename=(.*)/)
filename = filenames[1] if filename.nil?
rescue
filename = LinkedData::Utils::Triples.last_iri_fragment(uri.request_uri) if filename.nil?
end
Expand Down

0 comments on commit 9997331

Please sign in to comment.