mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
fix(chat) - Issue 12217 - Allow url-escapable characters in links. (#12218)
This commit is contained in:
@@ -100,6 +100,13 @@ describe('highlightMentions', () => {
|
|||||||
const result = await highlightMentions(text);
|
const result = await highlightMentions(text);
|
||||||
expect(result[0]).to.equal('http://www.medium.com/@user/blog [@user](/profile/111)');
|
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', () => {
|
describe('exceptions in code blocks', () => {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function toSourceMapRegex (token) {
|
|||||||
} else if (type === 'link_open') {
|
} else if (type === 'link_open') {
|
||||||
const texts = token.textContents.map(escapeRegExp);
|
const texts = token.textContents.map(escapeRegExp);
|
||||||
regexStr = markup === 'linkify' || markup === 'autolink' ? texts[0]
|
regexStr = markup === 'linkify' || markup === 'autolink' ? texts[0]
|
||||||
: `\\[.*${texts.join('.*')}.*\\]\\(${escapeRegExp(token.attrs[0][1])}\\)`;
|
: `\\[.*${texts.join('.*')}.*\\]\\([^)]+\\)`;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`No source mapping regex defined for ignore blocks of type ${type}`);
|
throw new Error(`No source mapping regex defined for ignore blocks of type ${type}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user