diff --git a/chat-formatter.js b/chat-formatter.js index a91f6e0f98..0344f59e5f 100644 --- a/chat-formatter.js +++ b/chat-formatter.js @@ -277,11 +277,12 @@ class TextFormatter { term += ` <${shortUri}>`; } if (colonPos > 0) { - switch (this.slice(start + 2, colonPos)) { + const key = this.slice(start + 2, colonPos); + switch (key) { case 'w': case 'wiki': - term = term.slice(term.charAt(5) === ' ' ? 6 : 5); - uri = `http://en.wikipedia.org/w/index.php?title=Special:Search&search=${this.toUriComponent(term)}`; + term = term.slice(term.charAt(key.length + 1) === ' ' ? key.length + 2 : key.length + 1); + uri = `//en.wikipedia.org/w/index.php?title=Special:Search&search=${this.toUriComponent(term)}`; term = `wiki: ${term}`; break; } diff --git a/test/application/chat.js b/test/application/chat.js index 3e98eaf7eb..df2b080660 100644 --- a/test/application/chat.js +++ b/test/application/chat.js @@ -62,7 +62,7 @@ describe('Chat', function () { ); assert.strictEqual( Chat.formatText(`[[wiki: Pokemon]]`, true), - `wiki: Pokemon` + `wiki: Pokemon` ); assert.strictEqual( Chat.formatText(`:)`, true),