Merge pull request #4481 from matrix-org/travis/fix-widget-params-again
Fix widget URL templating (again)pull/21833/head
commit
d8eb761106
|
@ -566,15 +566,18 @@ export default class AppTile extends React.Component {
|
||||||
* Replace the widget template variables in a url with their values
|
* Replace the widget template variables in a url with their values
|
||||||
*
|
*
|
||||||
* @param {string} u The URL with template variables
|
* @param {string} u The URL with template variables
|
||||||
|
* @param {string} widgetType The widget's type
|
||||||
*
|
*
|
||||||
* @returns {string} url with temlate variables replaced
|
* @returns {string} url with temlate variables replaced
|
||||||
*/
|
*/
|
||||||
_templatedUrl(u) {
|
_templatedUrl(u, widgetType: string) {
|
||||||
|
const targetData = {};
|
||||||
|
if (WidgetType.JITSI.matches(widgetType)) {
|
||||||
|
targetData['domain'] = 'jitsi.riot.im'; // v1 jitsi widgets have this hardcoded
|
||||||
|
}
|
||||||
const myUserId = MatrixClientPeg.get().credentials.userId;
|
const myUserId = MatrixClientPeg.get().credentials.userId;
|
||||||
const myUser = MatrixClientPeg.get().getUser(myUserId);
|
const myUser = MatrixClientPeg.get().getUser(myUserId);
|
||||||
const vars = Object.assign({
|
const vars = Object.assign(targetData, this.props.app.data, {
|
||||||
domain: "jitsi.riot.im", // v1 widgets have this hardcoded
|
|
||||||
}, this.props.app.data, {
|
|
||||||
'matrix_user_id': myUserId,
|
'matrix_user_id': myUserId,
|
||||||
'matrix_room_id': this.props.room.roomId,
|
'matrix_room_id': this.props.room.roomId,
|
||||||
'matrix_display_name': myUser ? myUser.displayName : myUserId,
|
'matrix_display_name': myUser ? myUser.displayName : myUserId,
|
||||||
|
@ -611,18 +614,19 @@ export default class AppTile extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
url = this._getSafeUrl(this.state.widgetUrl);
|
url = this._getSafeUrl(this.state.widgetUrl);
|
||||||
}
|
}
|
||||||
return this._templatedUrl(url);
|
return this._templatedUrl(url, this.props.app.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getPopoutUrl() {
|
_getPopoutUrl() {
|
||||||
if (WidgetType.JITSI.matches(this.props.app.type)) {
|
if (WidgetType.JITSI.matches(this.props.app.type)) {
|
||||||
return this._templatedUrl(
|
return this._templatedUrl(
|
||||||
WidgetUtils.getLocalJitsiWrapperUrl({forLocalRender: false}),
|
WidgetUtils.getLocalJitsiWrapperUrl({forLocalRender: false}),
|
||||||
|
this.props.app.type,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// use app.url, not state.widgetUrl, because we want the one without
|
// use app.url, not state.widgetUrl, because we want the one without
|
||||||
// the wURL params for the popped-out version.
|
// the wURL params for the popped-out version.
|
||||||
return this._templatedUrl(this._getSafeUrl(this.props.app.url));
|
return this._templatedUrl(this._getSafeUrl(this.props.app.url), this.props.app.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +640,10 @@ export default class AppTile extends React.Component {
|
||||||
if (ALLOWED_APP_URL_SCHEMES.includes(parsedWidgetUrl.protocol)) {
|
if (ALLOWED_APP_URL_SCHEMES.includes(parsedWidgetUrl.protocol)) {
|
||||||
safeWidgetUrl = url.format(parsedWidgetUrl);
|
safeWidgetUrl = url.format(parsedWidgetUrl);
|
||||||
}
|
}
|
||||||
return safeWidgetUrl;
|
|
||||||
|
// Replace all the dollar signs back to dollar signs as they don't affect HTTP at all.
|
||||||
|
// We also need the dollar signs in-tact for variable substitution.
|
||||||
|
return safeWidgetUrl.replace(/%24/g, '$');
|
||||||
}
|
}
|
||||||
|
|
||||||
_getTileTitle() {
|
_getTileTitle() {
|
||||||
|
|
Loading…
Reference in New Issue