模块:Urldecode

来自决策链云智库
Zeroclanzhang讨论 | 贡献2024年1月16日 (二) 15:38的版本 (创建页面,内容为“local p = {} function p.urlDecode( frame ) local enctype = frame.args[2] local ret = nil; if (frame.args[2] ~= nil) then enctype = mw.ustring.upper(enctype) if ((enctype == "QUERY") or (enctype == "PATH") or (enctype == "WIKI")) then ret = mw.uri.decode(frame.args[1],frame.args[2]) end else ret = mw.uri.decode(frame.args[1]) end ret = string.gsub(ret, "{", "{") ret = string.gsub(ret, "}", "}") return ret end return p”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

Functions

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

See also


local p = {}

function p.urlDecode( frame )
	local enctype = frame.args[2]
	local ret = nil;
	if (frame.args[2] ~= nil) then
		enctype = mw.ustring.upper(enctype)
		if ((enctype == "QUERY") or (enctype == "PATH") or (enctype == "WIKI")) then
			ret = mw.uri.decode(frame.args[1],frame.args[2])
		end
	else
		ret = mw.uri.decode(frame.args[1])
	end
	ret = string.gsub(ret, "{", "{")
	ret = string.gsub(ret, "}", "}")

	return ret
end

return p