mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-06-02 22:08:36 -05:00
Formatter: Fix parsing for [[wiki: links]]
This commit is contained in:
parent
d0f66895c3
commit
3c5b4ca0fb
|
|
@ -277,11 +277,12 @@ class TextFormatter {
|
|||
term += `<small> <${shortUri}></small>`;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ describe('Chat', function () {
|
|||
);
|
||||
assert.strictEqual(
|
||||
Chat.formatText(`[[wiki: Pokemon]]`, true),
|
||||
`<a href="http://en.wikipedia.org/w/index.php?title=Special:Search&search=%20Pokemon" target="_blank" rel="noopener">wiki: Pokemon</a>`
|
||||
`<a href="//en.wikipedia.org/w/index.php?title=Special:Search&search=Pokemon" target="_blank" rel="noopener">wiki: Pokemon</a>`
|
||||
);
|
||||
assert.strictEqual(
|
||||
Chat.formatText(`:)`, true),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user