fix(util) fix parsing strings in parseURLParams

After https://github.com/jitsi/jitsi-meet/pull/11607 we might call it
with a string. Be nice and accept that in addition to URL objects.
This commit is contained in:
Saúl Ibarra Corretgé 2022-06-18 21:23:40 +02:00 committed by Saúl Ibarra Corretgé
parent 4d8f29d4fe
commit 2c5b132483
1 changed files with 5 additions and 1 deletions

View File

@ -23,9 +23,13 @@ const blacklist = [ '__proto__', 'constructor', 'prototype' ];
* @returns {Object}
*/
export function parseURLParams(
url: URL,
url: URL | string,
dontParse: boolean = false,
source: string = 'hash'): Object {
if (typeof url === 'string') {
// eslint-disable-next-line no-param-reassign
url = new URL(url);
}
const paramStr = source === 'search' ? url.search : url.hash;
const params = {};
const paramParts = (paramStr && paramStr.substr(1).split('&')) || [];