Module: Gadgeto::SanitizeFilename
- Defined in:
- lib/gadgeto/sanitize_filename.rb
Instance Method Summary collapse
Instance Method Details
#sanitize_filename(filename) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/gadgeto/sanitize_filename.rb', line 4 def sanitize_filename(filename) return filename unless filename filename.strip.tap do |fn| # get only the filename fn.gsub! /^.*(\\|\/)/, '' fn.gsub! /[^A-Za-z0-9\.\-]/, '_' end end |