Is there a function to decode an url?

  • What are you attempting to achieve?
    I would like to decode an url.
  • What is the issue?
    There is no such function. All I found it HTTPService:JSONEncode(), but I need decode
  • What solutions have you tried so far?
    Searched the wiki, just tested :JSONDecode()

So, is there something to decode an url? Thanks in advance!

function decodeChar(hex)
	return string.char(tonumber(hex,16))
end
 
function decodeString(str)
	local output, t = string.gsub(str,"%%(%x%x)",decodeChar)
	return output
end
 
-- will print "http://foo bar/"
print(decodeString("http%3A%2F%2Ffoo%20bar%2F"))

from RosettaCode

8 Likes

Thanks so much!