Module:Urldecode

From Wikinews, the free news source you can write!
Jump to navigation Jump to search
[edit] Documentation

Functions

  • Function urlDecode reverses the transformation by magic word {{urldecode:}}.
{{#invoke:Urldecode|urlDecode|C%C3%B4te+d%27Ivoire}}  would produce  Côte d'Ivoire
local p = {}

function p.urlDecode( frame )
	local enctype = frame.args[2]
	if (frame.args[2] ~= nil) then
		enctype = mw.ustring.upper(enctype)
		if ((enctype == "QUERY") or (enctype == "PATH") or (enctype == "WIKI")) then
			return (mw.uri.decode(frame.args[1],frame.args[2]))
		end
	end
	return (mw.uri.decode(frame.args[1]))
end

return p