From ca02ff493c6cd8cef6dc74fd3696b9884f521b2c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 21 Mar 2020 10:42:07 +0000 Subject: [PATCH 1/2] Fix local jitsi build url fail and missing argument Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/CallHandler.js | 2 +- src/utils/WidgetUtils.js | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 7ec4e7d8bb..86674afd7d 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -435,7 +435,7 @@ async function _startCallApp(roomId, type) { const confId = room.roomId.replace(/[^A-Za-z0-9]/g, '') + widgetSessionId; const jitsiDomain = SdkConfig.get()['jitsi']['preferredDomain']; - const widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl(); + const widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl({}); const widgetData = { widgetSessionId, // TODO: Remove this eventually diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 7d6bf5e90d..26e29b49f8 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -485,19 +485,16 @@ export default class WidgetUtils { 'userId=$matrix_user_id', ].join('&'); - let currentUrl = window.location.href.split('#')[0]; - if (!currentUrl.startsWith("https://") && !opts.forLocalRender) { + let baseUrl = window.location; + if (window.location.protocol !== "https:" && !opts.forLocalRender) { // Use an external wrapper if we're not locally rendering the widget. This is usually // the URL that will end up in the widget event, so we want to make sure it's relatively // safe to send. // We'll end up using a local render URL when we see a Jitsi widget anyways, so this is // really just for backwards compatibility and to appease the spec. - currentUrl = "https://riot.im/app"; + baseUrl = "https://riot.im/app"; } - if (!currentUrl.endsWith('/')) { - currentUrl = `${currentUrl}/`; - } - - return currentUrl + "jitsi.html#" + queryString; + const url = new URL("jitsi.html#" + queryString, baseUrl); // this strips hash fragment from baseUrl + return url.href; } } From 506927ad8aa7cdd1337b60dfd02db65c22a29169 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 21 Mar 2020 10:49:55 +0000 Subject: [PATCH 2/2] change to defaults Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/CallHandler.js | 2 +- src/utils/WidgetUtils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 86674afd7d..7ec4e7d8bb 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -435,7 +435,7 @@ async function _startCallApp(roomId, type) { const confId = room.roomId.replace(/[^A-Za-z0-9]/g, '') + widgetSessionId; const jitsiDomain = SdkConfig.get()['jitsi']['preferredDomain']; - const widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl({}); + const widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl(); const widgetData = { widgetSessionId, // TODO: Remove this eventually diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 26e29b49f8..e92fd1ed27 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -474,7 +474,7 @@ export default class WidgetUtils { return encodeURIComponent(`${widgetLocation}::${widgetUrl}`); } - static getLocalJitsiWrapperUrl(opts: {forLocalRender?: boolean}) { + static getLocalJitsiWrapperUrl(opts: {forLocalRender?: boolean}={}) { // NB. we can't just encodeURIComponent all of these because the $ signs need to be there const queryString = [ 'conferenceDomain=$domain',