Fix the jitsi qs parsing, as the `?` after `#` here is optional, unlike in EW

pull/13138/head
Michael Telatynski 2021-07-16 19:37:48 +01:00
parent 26fef6f294
commit c7a935777d
1 changed files with 7 additions and 7 deletions

View File

@ -17,7 +17,6 @@ limitations under the License.
// We have to trick webpack into loading our CSS for us.
require("./index.scss");
import { parseQs, parseQsFromFragment } from "../url_utils";
import { KJUR } from 'jsrsasign';
import {
IOpenIDCredentials,
@ -52,15 +51,16 @@ let meetApi: any; // JitsiMeetExternalAPI
(async function() {
try {
// The widget's options are encoded into the fragment to avoid leaking info to the server. The widget
// spec on the other hand requires the widgetId and parentUrl to show up in the regular query string.
const widgetQuery = parseQsFromFragment(window.location);
const query = Object.assign({}, parseQs(window.location), widgetQuery.params);
// The widget's options are encoded into the fragment to avoid leaking info to the server.
const widgetQuery = new URLSearchParams(window.location.hash.substring(1));
// The widget spec on the other hand requires the widgetId and parentUrl to show up in the regular query string.
const realQuery = new URLSearchParams(window.location.search.substring(1));
const qsParam = (name: string, optional = false): string => {
if (!optional && (!query[name] || typeof (query[name]) !== 'string')) {
const vals = widgetQuery.has(name) ? widgetQuery.getAll(name) : realQuery.getAll(name);
if (!optional && vals.length !== 1) {
throw new Error(`Expected singular ${name} in query string`);
}
return <string>query[name];
return <string>vals[0];
};
// If we have these params, expect a widget API to be available (ie. to be in an iframe