|
@@ -47,6 +47,7 @@ export default class Wiki extends URL {
|
|
|
}
|
|
|
this.articlepath = articlepath;
|
|
|
this.mainpage = '';
|
|
|
+ this.mainpageisdomainroot = false;
|
|
|
this.miraheze = this.hostname.endsWith( '.miraheze.org' );
|
|
|
this.wikimedia = wikimediaSites.includes( this.hostname.split('.').slice(-2).join('.') );
|
|
|
this.centralauth = ( ( this.isWikimedia() || this.isMiraheze() ) ? 'CentralAuth' : 'local' );
|
|
@@ -86,11 +87,12 @@ export default class Wiki extends URL {
|
|
|
* @param {String} [siteinfo.gamepedia] - If the wiki is a Gamepedia wiki.
|
|
|
* @returns {Wiki}
|
|
|
*/
|
|
|
- updateWiki({servername, scriptpath, articlepath, mainpage, centralidlookupprovider, logo, gamepedia = 'false'}) {
|
|
|
+ updateWiki({servername, scriptpath, articlepath, mainpage, mainpageisdomainroot, centralidlookupprovider, logo, gamepedia = 'false'}) {
|
|
|
this.hostname = servername;
|
|
|
this.pathname = scriptpath + '/';
|
|
|
this.articlepath = articlepath;
|
|
|
this.mainpage = mainpage;
|
|
|
+ this.mainpageisdomainroot = ( mainpageisdomainroot !== undefined );
|
|
|
this.centralauth = centralidlookupprovider;
|
|
|
this.miraheze = /^(?:https?:)?\/\/static\.miraheze\.org\//.test(logo);
|
|
|
this.gamepedia = ( gamepedia === 'true' ? true : this.hostname.endsWith( '.gamepedia.com' ) );
|
|
@@ -175,6 +177,7 @@ export default class Wiki extends URL {
|
|
|
* @returns {String}
|
|
|
*/
|
|
|
toLink(title = '', querystring = '', fragment = '', isMarkdown = false) {
|
|
|
+ if ( this.mainpageisdomainroot && title === this.mainpage && !querystring ) return this.origin + '/' + Wiki.toSection(fragment, true, this.spaceReplacement);
|
|
|
querystring = new URLSearchParams(querystring);
|
|
|
if ( !querystring.toString().length ) title = ( title || this.mainpage );
|
|
|
title = title.replace( / /g, this.spaceReplacement ).replace( /%/g, '%2525' );
|
|
@@ -283,7 +286,8 @@ export default class Wiki extends URL {
|
|
|
articlepath: this.articlepath,
|
|
|
articleURL: this.articleURL,
|
|
|
spaceReplacement: this.spaceReplacement,
|
|
|
- mainpage: this.mainpage
|
|
|
+ mainpage: this.mainpage,
|
|
|
+ mainpageisdomainroot: this.mainpageisdomainroot,
|
|
|
}
|
|
|
return 'Wiki ' + inspect(wiki, opts);
|
|
|
}
|