Parcourir la source

Handle special case of two `@` signs preceding a nickname

JC Brand il y a 4 ans
Parent
commit
c608958eb3
2 fichiers modifiés avec 10 ajouts et 1 suppressions
  1. 6 0
      spec/mentions.js
  2. 4 1
      src/headless/converse-muc.js

+ 6 - 0
spec/mentions.js

@@ -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');

+ 4 - 1
src/headless/converse-muc.js

@@ -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]);