I want to find File extensions like .gif,.jpg,.txt from the uri like http://testasp.vulnweb.com/avatars/noavatar.gif.
GetFileName() and Path. GetExtension() methods to get the file name and file type (or extension) of a given URL.
extname() or extname() function of the File class in Ruby gets the extension of a file. For example, this function will return the extension of a Ruby application file main. rb as . rb .
You can use an extname method of File
url = "http://testasp.vulnweb.com/avatars/noavatar.gif"
File.extname(url) #=> .gif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With