Skip to content

Commit 004e12a

Browse files
committed
don't break links with brackets
1 parent 221f2bb commit 004e12a

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

RcGcDb

Submodule RcGcDb updated from 1e53f24 to 7a92d67

cmds/wiki/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default function mw_search(lang, msg, searchterm, wiki, query, reaction,
9898
if ( !hasExactMatch ) {
9999
if ( query.interwiki?.[0] ) {
100100
let text = '• **⤷ ';
101-
text += '__[' + escapeFormatting(query.interwiki[0].title) + '](<' + query.interwiki[0].url.replace( /[()]/g, '\\$&' ) + '>)__';
101+
text += '__[' + escapeFormatting(query.interwiki[0].title) + '](<' + query.interwiki[0].url + '>)__';
102102
if ( query.redirects?.[0] ) {
103103
text += ' (⤷ [' + escapeFormatting(query.redirects[0].from) + '](<' + wiki.toLink(query.redirects[0].from, 'redirect=no', '', true) + '>))';
104104
}

package-lock.json

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"htmlparser2": "^10.0.0",
2828
"mediawiki-projects-list": "^4.9.3",
2929
"npm": "^11.4.2",
30-
"pg": "^8.16.0"
30+
"pg": "^8.16.1"
3131
},
3232
"repository": {
3333
"type": "git",

util/functions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ function htmlToDiscord(html, pagelink = '', ...escapeArgs) {
383383
if ( tagname === 'a' && attribs.href && !classes.includes( 'new' ) && !classes.includes( 'ext-discussiontools-init-timestamplink' ) && /^(?:(?:https?:)?\/\/|\/|#)/.test(attribs.href) ) {
384384
try {
385385
if ( relativeFix && /^\/(?!\/)/.test(attribs.href) ) attribs.href = relativeFix(attribs.href, pagelink);
386-
href = new URL(attribs.href, pagelink).href.replace( /[()]/g, '\\$&' );
386+
href = new URL(attribs.href, pagelink);
387387
if ( text.trim().endsWith( '](<' + href + '>)' ) ) {
388388
let whitespace = text.match( /(?<=>\))\s*$/ )?.[0] ?? '';
389389
text = text.substring(0, text.length - ( href.length + 5 + whitespace.length )) + whitespace;
@@ -504,7 +504,7 @@ function escapeRegExp(text = '') {
504504
function limitLength(text = '', limit = 1_000, maxExtra = 20) {
505505
var suffix = '\u2026';
506506
var link = null;
507-
var regex = /(?<!\\)\[((?:[^\[\]]|\\[\[\]])*?[^\\])\]\(<?(?:[^()]|\\[()])+?[^\\]>?\)/g;
507+
var regex = /(?<!\\)\[((?:[^\[\]]|\\[\[\]])*?[^\\])\]\(<?(?:[^<>]|\\[<>])+?[^\\]>?\)/g;
508508
while ( ( link = regex.exec(text) ) !== null ) {
509509
if ( link.index < limit && link.index + link[0].length > limit ) {
510510
if ( link.index + link[0].length < limit + maxExtra ) suffix = link[0];

util/wiki.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export default class Wiki extends URL {
291291
static toTitle(title = '', spaceReplacement = '_') {
292292
return title.replaceAll( ' ', spaceReplacement ).replace( /[?&%\\]/g, (match) => {
293293
return '%' + match.charCodeAt().toString(16).toUpperCase();
294-
} ).replace( /@(here|everyone)/g, '%40$1' ).replace( /[()]/g, '\\$&' );
294+
} ).replace( /@(here|everyone)/g, '%40$1' );
295295
};
296296

297297
/**

0 commit comments

Comments
 (0)