Sha256: 9e037cd5949c35e00446e308ccb6e64f3560795bc0ebfac182470834d53201c0
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module ActiveEncode module FilenameSanitizer # ffmpeg has trouble with double quotes in file names. Escape them to get ffmpeg to find the file. def sanitize_input(input_url) input_url.gsub(/["]/, '\\\\\0') end def sanitize_base(input_url) filepath = input_url.is_a?(URI::HTTP) ? input_url.path : input_url # Replace special characters with underscores and remove excess periods. # This removes the extension before processing so it is safe to delete all detected periods. File.basename(filepath, File.extname(filepath)).gsub(/[^0-9A-Za-z.\-\/]/, '_').delete('.') end def sanitize_filename(input_url) filepath = input_url.is_a?(URI::HTTP) ? input_url.path : input_url # Replace special characters with underscores and remove excess periods. File.basename(filepath).gsub(/[^0-9A-Za-z.\-\/]/, '_').gsub(/\.(?=.*\.)/, '') end def sanitize_uri(input_url) case input_url when /^file\:\/\/\// input_url.to_s.gsub(/file:\/\//, '') when /^s3\:\/\// input_url.to_s.gsub(/#{input_url.normalized_site}/, '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_encode-1.1.2 | lib/active_encode/filename_sanitizer.rb |