Sha256: 7d794d2b9df9de5223246d1bacc2a922ca8da33d702f624b96041956a4fd2a1d
Contents?: true
Size: 735 Bytes
Versions: 2
Compression:
Stored size: 735 Bytes
Contents
require "cgi" module Down module Utils module_function # Retrieves potential filename from the "Content-Disposition" header. def filename_from_content_disposition(content_disposition) content_disposition = content_disposition.to_s escaped_filename = content_disposition[/filename\*=UTF-8''(\S+)/, 1] || content_disposition[/filename="([^"]*)"/, 1] || content_disposition[/filename=([^\s;]+)/, 1] filename = CGI.unescape(escaped_filename.to_s) filename unless filename.empty? end # Retrieves potential filename from the URL path. def filename_from_path(path) filename = path.split("/").last CGI.unescape(filename) if filename end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
down-5.4.2 | lib/down/utils.rb |
down-5.4.1 | lib/down/utils.rb |