Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2750954
mediawiki.action.view.redirect.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
mediawiki.action.view.redirect.js
View Options
/*!
* In general, MediaWiki does not ask browsers to resolve wiki page
* redirects client-side over HTTP. Instead, wiki page redirects are
* resolved server-side and rendered directly in response to a
* navigation.
*
* This script is responsible for:
*
* - Update the address bar to reflect the rendered destination.
*
* Given [[Foo]] redirecting to [[Bar]], when viewing [[Foo]]
* the server renders Bar content, with "Bar" as doc title
* and with "Bar" in the address bar.
*
* - For internal redirect destination that specify a fragment, if
* the navigation does not set its own fragment, scroll to the
* specified section.
*
* Given [[Foo]] redirecting to [[Bar#Foo]], the browser should
* scroll to "Foo", and render address bar Bar#Foo (not Foo, Bar,
* or Foo#Foo).
*
* Given [[Foo]] redirecting to [[Bar#Foo]], when navigating to
* [[Foo#Quux]], the address bar should reflect Bar#Quux, and
* let the native scroll happen, don't override scroll to #Foo.
*/
(
function
()
{
'use strict'
;
let
canonical
=
mw
.
config
.
get
(
'wgInternalRedirectTargetUrl'
);
if
(
!
canonical
)
{
return
;
}
let
fragment
=
null
;
if
(
location
.
hash
)
{
// Ignore redirect's own fragment and preserve fragment override in address
canonical
=
canonical
.
replace
(
/#.*$/
,
''
)
+
location
.
hash
;
}
else
{
const
index
=
canonical
.
indexOf
(
'#'
);
fragment
=
(
index
!==
-
1
)
?
canonical
.
slice
(
index
)
:
null
;
}
// Update address bar, including browser history.
// Preserve correct "Back"-button behaviour by using replaceState instead of
// pushState (or location.hash assignment)
history
.
replaceState
(
history
.
state
,
''
,
canonical
);
if
(
fragment
)
{
// Specification for history.replaceState() doesn't require browser to scroll,
// so scroll to be sure (see also T110501).
const
node
=
document
.
getElementById
(
fragment
.
slice
(
1
)
);
if
(
node
)
{
node
.
scrollIntoView
();
}
}
}()
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 17:32 (20 h, 27 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
44/a3/d9c3374d4a9ea8014f400b1487af
Default Alt Text
mediawiki.action.view.redirect.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment