Module talk:Redirect

Weird behaviour

"{{#invoke:redirect|main|File:Test.svg}}" = ""

On en:wp, the origin of this module, this code produces " File:Test.svg ". here, it produces blank. RZuo (talk) 09:03, 28 April 2023 (UTC)

Not weird and documented: "Gets the target of a redirect. If the page specified is not a redirect, returns nil" (when called from normal Lua functions, i.e. the empty string from MediaWiki Scribunto invokations). This also allows testing if pages are redirect in order to suppress them (notably when several alternate page names are tested, to select the appropriate one that exist, in a prefered order). If the non-existant page name was still returned, we would will not know if the target exists and would link to it in all cases, producing red links... So this is needed to support aliases (which are very frequent in Commons, such as page names with or without disambiguation suffixes, or with alternate synonyms, or during unification of names to allow the transition by still supporting old page names as long as they exist, and are not redirected to another page). verdy_p (talk) 22:21, 8 January 2025 (UTC)