@@ -19,32 +19,32 @@ import PermalinkConstructor, {PermalinkParts} from "./PermalinkConstructor";
1919/**
2020 * Generates permalinks that self-reference the running webapp
2121 */
22- export default class RiotPermalinkConstructor extends PermalinkConstructor {
23- _riotUrl : string ;
22+ export default class ElementPermalinkConstructor extends PermalinkConstructor {
23+ _elementUrl : string ;
2424
25- constructor ( riotUrl : string ) {
25+ constructor ( elementUrl : string ) {
2626 super ( ) ;
27- this . _riotUrl = riotUrl ;
27+ this . _elementUrl = elementUrl ;
2828
29- if ( ! this . _riotUrl . startsWith ( "http:" ) && ! this . _riotUrl . startsWith ( "https:" ) ) {
30- throw new Error ( "Riot prefix URL does not appear to be an HTTP(S) URL" ) ;
29+ if ( ! this . _elementUrl . startsWith ( "http:" ) && ! this . _elementUrl . startsWith ( "https:" ) ) {
30+ throw new Error ( "Element prefix URL does not appear to be an HTTP(S) URL" ) ;
3131 }
3232 }
3333
3434 forEvent ( roomId : string , eventId : string , serverCandidates : string [ ] ) : string {
35- return `${ this . _riotUrl } /#/room/${ roomId } /${ eventId } ${ this . encodeServerCandidates ( serverCandidates ) } ` ;
35+ return `${ this . _elementUrl } /#/room/${ roomId } /${ eventId } ${ this . encodeServerCandidates ( serverCandidates ) } ` ;
3636 }
3737
3838 forRoom ( roomIdOrAlias : string , serverCandidates : string [ ] ) : string {
39- return `${ this . _riotUrl } /#/room/${ roomIdOrAlias } ${ this . encodeServerCandidates ( serverCandidates ) } ` ;
39+ return `${ this . _elementUrl } /#/room/${ roomIdOrAlias } ${ this . encodeServerCandidates ( serverCandidates ) } ` ;
4040 }
4141
4242 forUser ( userId : string ) : string {
43- return `${ this . _riotUrl } /#/user/${ userId } ` ;
43+ return `${ this . _elementUrl } /#/user/${ userId } ` ;
4444 }
4545
4646 forGroup ( groupId : string ) : string {
47- return `${ this . _riotUrl } /#/group/${ groupId } ` ;
47+ return `${ this . _elementUrl } /#/group/${ groupId } ` ;
4848 }
4949
5050 forEntity ( entityId : string ) : string {
@@ -58,7 +58,7 @@ export default class RiotPermalinkConstructor extends PermalinkConstructor {
5858 }
5959
6060 isPermalinkHost ( testHost : string ) : boolean {
61- const parsedUrl = new URL ( this . _riotUrl ) ;
61+ const parsedUrl = new URL ( this . _elementUrl ) ;
6262 return testHost === ( parsedUrl . host || parsedUrl . hostname ) ; // one of the hosts should match
6363 }
6464
@@ -69,13 +69,13 @@ export default class RiotPermalinkConstructor extends PermalinkConstructor {
6969
7070 // Heavily inspired by/borrowed from the matrix-bot-sdk (with permission):
7171 // https://github.com/turt2live/matrix-js-bot-sdk/blob/7c4665c9a25c2c8e0fe4e509f2616505b5b66a1c/src/Permalinks.ts#L33-L61
72- // Adapted for Riot 's URL format
72+ // Adapted for Element 's URL format
7373 parsePermalink ( fullUrl : string ) : PermalinkParts {
74- if ( ! fullUrl || ! fullUrl . startsWith ( this . _riotUrl ) ) {
74+ if ( ! fullUrl || ! fullUrl . startsWith ( this . _elementUrl ) ) {
7575 throw new Error ( "Does not appear to be a permalink" ) ;
7676 }
7777
78- const parts = fullUrl . substring ( `${ this . _riotUrl } /#/` . length ) . split ( "/" ) ;
78+ const parts = fullUrl . substring ( `${ this . _elementUrl } /#/` . length ) . split ( "/" ) ;
7979 if ( parts . length < 2 ) { // we're expecting an entity and an ID of some kind at least
8080 throw new Error ( "URL is missing parts" ) ;
8181 }
@@ -100,7 +100,7 @@ export default class RiotPermalinkConstructor extends PermalinkConstructor {
100100 const eventId = secondaryParts [ 0 ] ;
101101 const query = secondaryParts . length > 1 ? secondaryParts [ 1 ] : "" ;
102102
103- // TODO: Verify Riot works with via args
103+ // TODO: Verify Element works with via args
104104 const via = query . split ( "via=" ) . filter ( p => ! ! p ) ;
105105
106106 return PermalinkParts . forEvent ( entity , eventId , via ) ;
0 commit comments