<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.ooda.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect%2Fdoc</id>
	<title>Module:Redirect/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.ooda.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARedirect%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.ooda.wiki/index.php?title=Module:Redirect/doc&amp;action=history"/>
	<updated>2026-04-09T12:29:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.ooda.wiki/index.php?title=Module:Redirect/doc&amp;diff=570&amp;oldid=prev</id>
		<title>AdminIsidore: Created page with &quot;{{used in system}} {{Module rating|beta}} {{Module rating|protected}} {{Lua|Module:Arguments}} This module contains functions to find the target of a redirect page.  == Main ==  The main function accepts the name of a single page.  It determines if the page is a redirect; if so it looks up the page, extracts the target, and returns the target name as text. Its usage is &lt;code&gt;&lt;nowiki&gt;{{#invoke:redirect|main|page-name}}&lt;/nowiki&gt;&lt;/code&gt;. If &lt;code&gt;page-name...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.ooda.wiki/index.php?title=Module:Redirect/doc&amp;diff=570&amp;oldid=prev"/>
		<updated>2025-08-09T15:33:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{used in system}} {{Module rating|beta}} {{Module rating|protected}} {{Lua|Module:Arguments}} This module contains functions to find the target of a &lt;a href=&quot;/index.php?title=Help:Redirect&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Help:Redirect (page does not exist)&quot;&gt;redirect&lt;/a&gt; page.  == Main ==  The main function accepts the name of a single page.  It determines if the page is a redirect; if so it looks up the page, extracts the target, and returns the target name as text. Its usage is &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|main|page-name}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;page-name...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{used in system}}&lt;br /&gt;
{{Module rating|beta}}&lt;br /&gt;
{{Module rating|protected}}&lt;br /&gt;
{{Lua|Module:Arguments}}&lt;br /&gt;
This module contains functions to find the target of a [[Help:Redirect|redirect]] page.&lt;br /&gt;
&lt;br /&gt;
== Main ==&lt;br /&gt;
&lt;br /&gt;
The main function accepts the name of a single page.  It determines if the page is a redirect; if so it looks up the page, extracts the target, and returns the target name as text. Its usage is &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|main|page-name}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;page-name&amp;lt;/code&amp;gt; does not exist or is not a redirect then &amp;lt;code&amp;gt;page-name&amp;lt;/code&amp;gt; is returned. If &amp;lt;code&amp;gt;page-name&amp;lt;/code&amp;gt; is blank then blank is returned.&lt;br /&gt;
&lt;br /&gt;
The function normally neither takes nor gives square brackets, so to show the result as a link use &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[{{#invoke:redirect|main|page-name}}]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
If the parameter &amp;#039;&amp;#039;bracket&amp;#039;&amp;#039; is given a nonblank value, brackets will be passed on if present.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|main|WP:AFC}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|main|WP:AFC}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|main|[[WP:AFD]]|bracket=yes}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|main|[[WP:AFD]]|bracket=yes}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|main|OODAWIKI:Articles for deletion}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|main|OODAWIKI:Articles for deletion}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|main|OODAWIKI:Articles for rumination}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|main|OODAWIKI:Articles for rumination}}&lt;br /&gt;
&lt;br /&gt;
Note: [[WP:AFC]] and [[WP:AFD]] are both redirects, but [[OODAWIKI:Articles for deletion]] is not, and [[OODAWIKI:Articles for rumination]] does not exist.&lt;br /&gt;
&lt;br /&gt;
=== LuaMain ===&lt;br /&gt;
&lt;br /&gt;
If you want to use the main function from another Lua module, you may want to use the luaMain function. This provides the same functionality as the main function, but doesn&amp;#039;t require that a frame object be available.&lt;br /&gt;
&lt;br /&gt;
To use this, first load the module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local mRedirect = require(&amp;#039;Module:Redirect&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then use the function with the following syntax: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mRedirect.luaMain(rname, bracket)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;var&amp;gt;rname&amp;lt;/var&amp;gt; is the name of the redirect page, and if &amp;lt;var&amp;gt;bracket&amp;lt;/var&amp;gt; is anything but false or nil, the module will produce a link rather than just a page name.&lt;br /&gt;
&lt;br /&gt;
== IsRedirect ==&lt;br /&gt;
&lt;br /&gt;
The isRedirect function is used from wiki pages to find out if a given page is a redirect or not. If the page is a redirect, the function returns &amp;quot;yes&amp;quot;, and if not the output is blank. Its usage is &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|isRedirect|page-name}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|isRedirect|WP:AFC}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|isRedirect|WP:AFC}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|isRedirect|OODAWIKI:Articles for deletion}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|isRedirect|OODAWIKI:Articles for deletion}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:redirect|isRedirect|OODAWIKI:Articles for rumination}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;amp;rarr; {{#invoke:redirect|isRedirect|OODAWIKI:Articles for rumination}}&lt;br /&gt;
&lt;br /&gt;
=== LuaIsRedirect ===&lt;br /&gt;
The isRedirect can be accessed from other Lua modules in the same way as the main function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local mRedirect = require(&amp;#039;Module:Redirect&amp;#039;)&lt;br /&gt;
mRedirect.luaIsRedirect(rname)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetTarget ==&lt;br /&gt;
&lt;br /&gt;
The getTarget function fetches the target page name of a redirect page, and is only usable from Lua. If the page specified is a redirect, then the target is returned; otherwise the function returns nil.&lt;br /&gt;
&lt;br /&gt;
To use it, first load the module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local mRedirect = require(&amp;#039;Module:Redirect&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then use the function with the following syntax: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mRedirect.getTarget(page)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;var&amp;gt;page&amp;lt;/var&amp;gt; can be either the name of the redirect page as a string, or a [[mw:Extension:Scribunto/Lua reference manual#Title objects|mw.title object]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[phab:T68974]] -  Provide a standard way to get the target of a redirect page&lt;br /&gt;
* [[mw:Extension:Scribunto/Lua reference manual#Title objects]], the Scribunto interface for determining a page&amp;#039;s redirect status&lt;br /&gt;
* [[Template:Get QID]], which uses this module &lt;br /&gt;
* [[Template:Submit an edit request]], which uses this module&lt;/div&gt;</summary>
		<author><name>AdminIsidore</name></author>
	</entry>
</feed>