Markus-Rost 4 lat temu
rodzic
commit
19c2aa9359
2 zmienionych plików z 3 dodań i 3 usunięć
  1. 1 1
      cmds/eval.js
  2. 2 2
      util/wiki.js

+ 1 - 1
cmds/eval.js

@@ -94,7 +94,7 @@ function checkWiki(wiki) {
 				if ( dsresponse.statusCode !== 200 || !dsbody || dsbody.title ) {
 					if ( dsbody?.title !== 'site doesn\'t exists' ) result.postid = dsresponse.statusCode + ': Error while getting the discussions: ' + dsbody?.title;
 				}
-				else result.postid = ( dsbody._embedded?.['doc:posts']?.id || 0 );
+				else result.postid = ( dsbody._embedded?.['doc:posts']?.[0]?.id || 0 );
 			}, error => {
 				result.postid = 'Error while getting the discussions: ' + error;
 			} ) : null )

+ 2 - 2
util/wiki.js

@@ -146,7 +146,7 @@ class Wiki extends URL {
 	toLink(title = '', querystring = '', fragment = '', isMarkdown = false) {
 		querystring = new URLSearchParams(querystring);
 		if ( !querystring.toString().length ) title = ( title || this.mainpage );
-		title = title.replace( / /g, '_' );
+		title = title.replace( / /g, '_' ).replace( /%/g, '%2525' );
 		let link = new URL(this.articleURL);
 		link.pathname = link.pathname.replace( '$1', title.replace( /\\/g, '%5C' ) );
 		link.searchParams.forEach( (value, name, searchParams) => {
@@ -159,7 +159,7 @@ class Wiki extends URL {
 			link.searchParams.append(name, value);
 		} );
 		let output = decodeURI( link ).replace( /\\/g, '%5C' ).replace( /@(here|everyone)/g, '%40$1' );
-		if ( isMarkdown ) output = output.replace( /([\(\)])/g, '\\$1' );
+		if ( isMarkdown ) output = output.replace( /[()]/g, '\\$&' );
 		return output + Wiki.toSection(fragment);
 	}