rn: support passing serverURL and room to URL object

That's what the SDK passes now, if the room URL is not absolute.
This commit is contained in:
Saúl Ibarra Corretgé 2019-03-06 13:12:54 +01:00
parent 5b3e8a9b5e
commit 975ff9c83d
1 changed files with 13 additions and 1 deletions

View File

@ -377,7 +377,19 @@ export function toURLString(obj: ?(Object | string)): ?string {
* {@code Object}.
*/
export function urlObjectToString(o: Object): ?string {
const url = parseStandardURIString(_fixURIStringScheme(o.url || ''));
// 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) {