@@ -19,6 +19,7 @@ import {
1919 makeGroupPermalink ,
2020 makeRoomPermalink ,
2121 makeUserPermalink ,
22+ parsePermalink ,
2223 RoomPermalinkCreator ,
2324} from "../../../src/utils/permalinks/Permalinks" ;
2425import * as testUtils from "../../test-utils" ;
@@ -450,4 +451,24 @@ describe('Permalinks', function() {
450451 const result = makeGroupPermalink ( "+community:example.org" ) ;
451452 expect ( result ) . toBe ( "https://matrix.to/#/+community:example.org" ) ;
452453 } ) ;
454+
455+ it ( 'should correctly parse room permalinks with a via argument' , ( ) => {
456+ const result = parsePermalink ( "https://matrix.to/#/!room_id:server?via=some.org" ) ;
457+ expect ( result . roomIdOrAlias ) . toBe ( "!room_id:server" ) ;
458+ expect ( result . viaServers ) . toEqual ( [ "some.org" ] ) ;
459+ } ) ;
460+
461+ it ( 'should correctly parse room permalink via arguments' , ( ) => {
462+ const result = parsePermalink ( "https://matrix.to/#/!room_id:server?via=foo.bar&via=bar.foo" ) ;
463+ expect ( result . roomIdOrAlias ) . toBe ( "!room_id:server" ) ;
464+ expect ( result . viaServers ) . toEqual ( [ "foo.bar" , "bar.foo" ] ) ;
465+ } ) ;
466+
467+ it ( 'should correctly parse event permalink via arguments' , ( ) => {
468+ const result = parsePermalink ( "https://matrix.to/#/!room_id:server/$event_id/some_thing_here/foobar" +
469+ "?via=m1.org&via=m2.org" ) ;
470+ expect ( result . eventId ) . toBe ( "$event_id/some_thing_here/foobar" ) ;
471+ expect ( result . roomIdOrAlias ) . toBe ( "!room_id:server" ) ;
472+ expect ( result . viaServers ) . toEqual ( [ "m1.org" , "m2.org" ] ) ;
473+ } ) ;
453474} ) ;
0 commit comments