in react/features/base/util/uri.js [452:568]
export function urlObjectToString(o: Object): ?string {
// First normalize the given url. It come as o.url or split into o.serverURL
// and o.room.
let tmp;
if (o.serverURL && o.room) {
tmp = new URL(o.room, o.serverURL).toString();
} else if (o.room) {
tmp = o.room;
} else {
tmp = o.url || '';
}
const url = parseStandardURIString(_fixURIStringScheme(tmp));
// protocol
if (!url.protocol) {
let protocol: ?string = o.protocol || o.scheme;
if (protocol) {
// Protocol is supposed to be the scheme and the final ':'. Anyway,
// do not make a fuss if the final ':' is not there.
protocol.endsWith(':') || (protocol += ':');
url.protocol = protocol;
}
}
// authority & pathname
let { pathname } = url;
if (!url.host) {
// Web's ExternalAPI domain
//
// It may be host/hostname and pathname with the latter denoting the
// tenant.
const domain: ?string = o.domain || o.host || o.hostname;
if (domain) {
const { host, hostname, pathname: contextRoot, port }
= parseStandardURIString(
// XXX The value of domain in supposed to be host/hostname
// and, optionally, pathname. Make sure it is not taken for
// a pathname only.
_fixURIStringScheme(`${APP_LINK_SCHEME}//${domain}`));
// authority
if (host) {
url.host = host;
url.hostname = hostname;
url.port = port;
}
// pathname
pathname === '/' && contextRoot !== '/' && (pathname = contextRoot);
}
}
// pathname
// Web's ExternalAPI roomName
const room = o.roomName || o.room;
if (room
&& (url.pathname.endsWith('/')
|| !url.pathname.endsWith(`/${room}`))) {
pathname.endsWith('/') || (pathname += '/');
pathname += room;
}
url.pathname = pathname;
// query/search
// Web's ExternalAPI jwt
const { jwt } = o;
if (jwt) {
let { search } = url;
if (search.indexOf('?jwt=') === -1 && search.indexOf('&jwt=') === -1) {
search.startsWith('?') || (search = `?${search}`);
search.length === 1 || (search += '&');
search += `jwt=${jwt}`;
url.search = search;
}
}
// fragment/hash
let { hash } = url;
for (const urlPrefix of [ 'config', 'interfaceConfig', 'devices', 'userInfo', 'appData' ]) {
const urlParamsArray
= _objectToURLParamsArray(
o[`${urlPrefix}Overwrite`]
|| o[urlPrefix]
|| o[`${urlPrefix}Override`]);
if (urlParamsArray.length) {
let urlParamsString
= `${urlPrefix}.${urlParamsArray.join(`&${urlPrefix}.`)}`;
if (hash.length) {
urlParamsString = `&${urlParamsString}`;
} else {
hash = '#';
}
hash += urlParamsString;
}
}
url.hash = hash;
return url.toString() || undefined;
}