fix(chat) - Issue 12217 - Allow url-escapable characters in links. (#12218)

This commit is contained in:
Bart Enkelaar
2020-05-19 17:28:55 +02:00
committed by GitHub
parent 1bc756ee93
commit 85d290a1fa
2 changed files with 8 additions and 1 deletions

View File

@@ -100,6 +100,13 @@ describe('highlightMentions', () => {
const result = await highlightMentions(text);
expect(result[0]).to.equal('http://www.medium.com/@user/blog [@user](/profile/111)');
});
// https://github.com/HabitRPG/habitica/issues/12217
it('doesn\'t highlight user in link with url-escapable characters', async () => {
const text = '[test](https://habitica.fandom.com/ru/@wiki/Снаряжение)';
const result = await highlightMentions(text);
expect(result[0]).to.equal(text);
});
});
describe('exceptions in code blocks', () => {

View File

@@ -86,7 +86,7 @@ function toSourceMapRegex (token) {
} else if (type === 'link_open') {
const texts = token.textContents.map(escapeRegExp);
regexStr = markup === 'linkify' || markup === 'autolink' ? texts[0]
: `\\[.*${texts.join('.*')}.*\\]\\(${escapeRegExp(token.attrs[0][1])}\\)`;
: `\\[.*${texts.join('.*')}.*\\]\\([^)]+\\)`;
} else {
throw new Error(`No source mapping regex defined for ignore blocks of type ${type}`);
}