Selaa lähdekoodia

fix interwiki

Markus-Rost 4 vuotta sitten
vanhempi
sitoutus
a605498bf2
4 muutettua tiedostoa jossa 6 lisäystä ja 6 poistoa
  1. 2 2
      cmds/wiki/fandom.js
  2. 2 2
      cmds/wiki/gamepedia.js
  3. 1 1
      main.js
  4. 1 1
      util/wiki.js

+ 2 - 2
cmds/wiki/fandom.js

@@ -437,9 +437,9 @@ function fandom_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '',
 				if ( project ) {
 					let regex = ( iw.host + iw.pathname ).match( new RegExp( '^' + project.regex + '(?:' + project.articlePath + '|/?$)' ) );
 					if ( regex ) {
-						let iwtitle = decodeURIComponent( iw.pathname.replace( regex[0], '' ) ).replace( /_/g, ' ' );
+						let iwtitle = decodeURIComponent( ( iw.host + iw.pathname ).replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						cmd = '!!' + regex[1] + ' ';
-						return this.gamepedia(lang, msg, iwtitle, new Wiki(iw.origin + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+						return this.gamepedia(lang, msg, iwtitle, new Wiki('https://' + regex[1] + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 					}
 				}
 			}

+ 2 - 2
cmds/wiki/gamepedia.js

@@ -356,9 +356,9 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 				if ( project ) {
 					let regex = ( iw.host + iw.pathname ).match( new RegExp( '^' + project.regex + '(?:' + project.articlePath + '|/?$)' ) );
 					if ( regex ) {
-						let iwtitle = decodeURIComponent( iw.pathname.replace( regex[0], '' ) ).replace( /_/g, ' ' );
+						let iwtitle = decodeURIComponent( ( iw.host + iw.pathname ).replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						cmd = '!!' + regex[1] + ' ';
-						return this.gamepedia(lang, msg, iwtitle, new Wiki(iw.origin + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+						return this.gamepedia(lang, msg, iwtitle, new Wiki('https://' + regex[1] + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 					}
 				}
 			}

+ 1 - 1
main.js

@@ -175,6 +175,6 @@ if ( isDebug && process.argv[3]?.startsWith( '--timeout:' ) ) {
 	setTimeout( () => {
 		console.log( `\n- Running for ${timeout} seconds, closing process!\n` );
 		manager.shards.forEach( shard => shard.kill() );
-		if ( typeof server !== 'undefined' ) server.kill('SIGTERM');
+		if ( typeof server !== 'undefined' ) server.kill();
 	}, timeout  * 1000 ).unref();
 }

+ 1 - 1
util/wiki.js

@@ -12,7 +12,7 @@ class Wiki extends URL {
 	 * @param {String|URL|Wiki} [base] - The base for the wiki.
 	 * @constructs Wiki
 	 */
-	constructor(wiki = defaultSettings.wiki, base) {
+	constructor(wiki = defaultSettings.wiki, base = defaultSettings.wiki) {
 		super(wiki, base);
 		this.protocol = 'https';
 		let articlepath = '/index.php?title=$1';