Handle special case of two @ signs preceding a nickname

This commit is contained in:
JC Brand 2020-11-27 22:00:38 +01:00
parent f86efca9a6
commit c608958eb3
2 changed files with 10 additions and 1 deletions

View File

@ -170,6 +170,12 @@ describe("A sent groupchat message", function () {
expect(references)
.toEqual([{"begin":3,"end":8,"value":"robot","type":"mention","uri":"xmpp:robot@montague.lit"}]);
[text, references] = view.model.parseTextForReferences('@@gh0st')
expect(text).toBe('@gh0st');
expect(references.length).toBe(1);
expect(references)
.toEqual([{"begin":1,"end":6,"value":"gh0st","type":"mention","uri":"xmpp:lounge@montague.lit/gh0st"}]);
[text, references] = view.model.parseTextForReferences('hello z3r0')
expect(references.length).toBe(0);
expect(text).toBe('hello z3r0');

View File

@ -996,7 +996,10 @@ converse.plugins.add('converse-muc', {
};
const matchToReference = match => {
const at_sign_index = match[0].indexOf('@');
let at_sign_index = match[0].indexOf('@');
if (match[0][at_sign_index+1] === '@') { // edge-case
at_sign_index += 1;
}
const begin = match.index + at_sign_index;
const end = begin + match[0].length - at_sign_index;
const value = getMatchingNickname(match[1]);