Sha256: 445a4b3d5683d8c66c2bb64d5128cd89f8db6f5495314d0dea2b024055a36a80
Contents?: true
Size: 444 Bytes
Versions: 10
Compression:
Stored size: 444 Bytes
Contents
class File # Cleans up a filename to ensure it will work on a filesystem. # # File.sanitize("yo+baby!") #=> 'yo+baby_' # File.sanitize(".what&up") #=> '.what_up' # # CREDIT: George Moschovitis def self.sanitize(filename) filename = File.basename(filename.gsub("\\", "/")) # work-around for IE filename.gsub!(/[^a-zA-Z0-9\.\-\+_]/,"_") filename = "_#{filename}" if filename =~ /^\.+$/ filename end end
Version data entries
10 entries across 9 versions & 2 rubygems