Module:Redirect: Difference between revisions

handle percent-encoding like MediaWiki does, from sandbox
m (Changed protection level for "Module:Redirect": High-risk template or module; used in system message ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite)))
(handle percent-encoding like MediaWiki does, from sandbox)
Line 17: Line 17:
-- redirect.
-- redirect.
function p.getTargetFromText(text)
function p.getTargetFromText(text)
return string.match(
local target = string.match(
text,
text,
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"
Line 24: Line 24:
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"
)
)
return target and mw.uri.decode(target, 'PATH')
end
end


Anonymous user