Thomas Swift

Running a West Coast Offense since ‘81

Entries from October 2007

URL Decoding in Ruby

October 14th, 2007 · No Comments

This is very simple.

require “cgi”

def url_decode(address)
clean_address = CGI::unescape(address)
end

final_address = url_decode(”http%3A%2F%2Fwww%2Ethomasswift%2Ecom%2Fblog%2Furl%2Ddecoding%2Din%2Druby%2F”)
puts final_address

Save it and run it.
If for some reason this doesn’t suit your need, here are some other resources I was checking out.
Eric Meyer’s URL Encoder/Decoder - Code is included, but didn’t work on backslashes.
Kurt Dommermuth’s Flash URL Encoded/Decoder
URLEncode Chart

[Read more →]

Tags: ruby