mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 11:22:31 +00:00
* fix: Moves getDialInConferenceID, so we can reuse conf mapper url generation. * fix: Moves getDialInNumbers, so we can reuse url generation. * squash: Moves dialInInfo page path to constants. * feat: Adds the location address as a param to the conf mapper request. * feat: Adds option conf mapper and numbers urls to contain parameters (?). * squash: Adds more doc comments. * squash: Makes sure we strip url params if any, and they do not reach fetch.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
/* @flow */
|
|
|
|
/**
|
|
* Gets a {@link URL} without hash and query/search params from a specific
|
|
* {@code URL}.
|
|
*
|
|
* @param {URL} url - The {@code URL} which may have hash and query/search
|
|
* params.
|
|
* @returns {URL}
|
|
*/
|
|
export function getURLWithoutParams(url: URL): URL {
|
|
const { hash, search } = url;
|
|
|
|
if ((hash && hash.length > 1) || (search && search.length > 1)) {
|
|
url = new URL(url.href); // eslint-disable-line no-param-reassign
|
|
url.hash = '';
|
|
url.search = '';
|
|
|
|
// XXX The implementation of URL at least on React Native appends ? and
|
|
// # at the end of the href which is not desired.
|
|
let { href } = url;
|
|
|
|
if (href) {
|
|
href.endsWith('#') && (href = href.substring(0, href.length - 1));
|
|
href.endsWith('?') && (href = href.substring(0, href.length - 1));
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
url.href === href || (url = new URL(href));
|
|
}
|
|
}
|
|
|
|
return url;
|
|
}
|
|
|
|
/**
|
|
* Gets a URL string without hash and query/search params from a specific
|
|
* {@code URL}.
|
|
*
|
|
* @param {URL} url - The {@code URL} which may have hash and query/search
|
|
* params.
|
|
* @returns {string}
|
|
*/
|
|
export function getURLWithoutParamsNormalized(url: URL): string {
|
|
const urlWithoutParams = getURLWithoutParams(url).href;
|
|
|
|
if (urlWithoutParams) {
|
|
return urlWithoutParams.toLowerCase();
|
|
}
|
|
|
|
return '';
|
|
}
|