@@ -307,6 +307,51 @@ describe("UnbanBanCommand", () => {
307307            expect ( bits ! . list ! . listShortcode ) . toBe ( "test" ) ; 
308308        } ) ; 
309309
310+         it ( "should be able to parse matrix.to links" ,  async  ( )  =>  { 
311+             const  mjolnir  =  createTestMjolnir ( ) ; 
312+             ( < any > mjolnir ) . policyListManager . lists  =  [ {  listShortcode : "test"  } ] ; 
313+             mjolnir . client . sendMessage  =  ( roomId : string ,  content : any ) : Promise < string >  =>  { 
314+                 throw  new  Error ( "sendMessage should not have been called: "  +  JSON . stringify ( content ) ) ; 
315+             } ; 
316+ 
317+             const  userCommand  =  "!mjolnir ban test https://matrix.to/#/@bad_user:test.org" ; 
318+             const  userBits  =  await  parseArguments ( "!a" ,  createFakeEvent ( userCommand ) ,  mjolnir ,  userCommand . split ( " " ) ) ; 
319+             expect ( userBits ! . ruleType ) . toBe ( RULE_USER ) ; 
320+             expect ( userBits ! . entity ) . toBe ( "@bad_user:test.org" ) ; 
321+             expect ( userBits ! . list ) . toBeDefined ( ) ; 
322+             expect ( userBits ! . list ! . listShortcode ) . toBe ( "test" ) ; 
323+             expect ( userBits ) . toBeTruthy ( ) ; 
324+             expect ( userBits ! . reason ) . toBeFalsy ( ) ; 
325+ 
326+             const  roomCommand  =  "!mjolnir ban test https://matrix.to/#/!bummerRoom:test.org" ; 
327+             const  commandBits  =  await  parseArguments ( 
328+                 "!a" , 
329+                 createFakeEvent ( roomCommand ) , 
330+                 mjolnir , 
331+                 roomCommand . split ( " " ) , 
332+             ) ; 
333+             expect ( commandBits ! . ruleType ) . toBe ( RULE_ROOM ) ; 
334+             expect ( commandBits ! . entity ) . toBe ( "!bummerRoom:test.org" ) ; 
335+             expect ( commandBits ! . list ) . toBeDefined ( ) ; 
336+             expect ( commandBits ! . list ! . listShortcode ) . toBe ( "test" ) ; 
337+             expect ( commandBits ) . toBeTruthy ( ) ; 
338+             expect ( commandBits ! . reason ) . toBeFalsy ( ) ; 
339+ 
340+             const  aliasCommand  =  "!mjolnir ban test https://matrix.to/#/#bad-actors:test.org" ; 
341+             const  aliasBits  =  await  parseArguments ( 
342+                 "!a" , 
343+                 createFakeEvent ( aliasCommand ) , 
344+                 mjolnir , 
345+                 aliasCommand . split ( " " ) , 
346+             ) ; 
347+             expect ( aliasBits ! . ruleType ) . toBe ( RULE_ROOM ) ; 
348+             expect ( aliasBits ! . entity ) . toBe ( "#bad-actors:test.org" ) ; 
349+             expect ( aliasBits ! . list ) . toBeDefined ( ) ; 
350+             expect ( aliasBits ! . list ! . listShortcode ) . toBe ( "test" ) ; 
351+             expect ( aliasBits ) . toBeTruthy ( ) ; 
352+             expect ( aliasBits ! . reason ) . toBeFalsy ( ) ; 
353+         } ) ; 
354+ 
310355        it ( "should error if wildcards used without --force" ,  async  ( )  =>  { 
311356            const  mjolnir  =  createTestMjolnir ( ) ; 
312357            ( < any > mjolnir ) . policyListManager . lists  =  [ {  listShortcode : "test"  } ] ; 
0 commit comments