mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-20 12:48:52 +00:00
fix(chat) - issue 12586 - can't put links without titles in message boxes (#12594)
This commit is contained in:
parent
82be621850
commit
7c4faf8b7a
2 changed files with 20 additions and 16 deletions
|
|
@ -171,28 +171,32 @@ describe('highlightMentions', () => {
|
|||
it('github issue 12118, method crashes when square brackets are used', async () => {
|
||||
const text = '[test]';
|
||||
|
||||
let err;
|
||||
const result = await highlightMentions(text);
|
||||
|
||||
try {
|
||||
await highlightMentions(text);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
|
||||
expect(err).to.be.undefined;
|
||||
expect(result[0]).to.equal(text);
|
||||
});
|
||||
|
||||
it('github issue 12138, method crashes when regex chars are used in code block', async () => {
|
||||
const text = '`[test]`';
|
||||
|
||||
let err;
|
||||
const result = await highlightMentions(text);
|
||||
|
||||
try {
|
||||
await highlightMentions(text);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
expect(result[0]).to.equal(text);
|
||||
});
|
||||
|
||||
expect(err).to.be.undefined;
|
||||
it('github issue 12586, method crashes when empty link is used', async () => {
|
||||
const text = '[]()';
|
||||
|
||||
const result = await highlightMentions(text);
|
||||
|
||||
expect(result[0]).to.equal(text);
|
||||
});
|
||||
|
||||
it('github issue 12586, method crashes when link without title is used', async () => {
|
||||
const text = '[](www.google.com)';
|
||||
|
||||
const result = await highlightMentions(text);
|
||||
|
||||
expect(result[0]).to.equal(text);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ function toSourceMapRegex (token) {
|
|||
} else if (type === 'code_inline') {
|
||||
regexStr = `${markup} ?${contentRegex} ?${markup}`;
|
||||
} else if (type === 'link_open') {
|
||||
const texts = token.textContents.map(escapeRegExp);
|
||||
const texts = token.textContents ? token.textContents.map(escapeRegExp) : [''];
|
||||
regexStr = markup === 'linkify' || markup === 'autolink' ? texts[0]
|
||||
: `\\[[^\\]]*${texts.join('[^\\]]*')}[^\\]]*\\]\\([^)]*\\)`;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue