Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2752540
urlGenerator.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
urlGenerator.js
View Options
/*
* Adapted from Vector
* All credits go to the developers behind Vector
* @see https://github.com/wikimedia/mediawiki-skins-Vector/blob/master/resources/skins.vector.search/urlGenerator.js
*/
/**
* @typedef {Record<string,string>} UrlParams
* @param {string} title
* @param {string} fulltext
*/
/**
* @callback generateUrl
* @param {SearchResult|string} page
* @param {UrlParams} [params]
* @return {string}
*/
/**
* @typedef {Object} UrlGenerator
* @property {generateUrl} generateUrl
*/
/**
* Generates URLs for suggestions.
*
* @return {UrlGenerator}
*/
function
urlGenerator
()
{
return
{
/**
* @param {SearchResult|string} page
* @param {UrlParams} params
* @return {string}
*/
generateUrl
(
page
,
params
=
{}
)
{
let
title
;
if
(
!
page
)
{
title
=
'Special:Search'
;
}
else
if
(
typeof
page
!==
'string'
)
{
const
fragment
=
page
.
fragment
;
title
=
page
.
title
;
if
(
fragment
)
{
title
+=
`#
${
fragment
}
`
;
}
}
else
{
title
=
page
;
}
return
mw
.
util
.
getUrl
(
title
,
params
);
}
};
}
/** @module urlGenerator */
module
.
exports
=
urlGenerator
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 20:07 (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5f/8f/288969ed23630b68c1f08160c113
Default Alt Text
urlGenerator.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment