From 968521ef7c70e737a26cb53613790eebedaa435b Mon Sep 17 00:00:00 2001 From: yanas Date: Fri, 3 Jun 2016 07:45:57 -0500 Subject: [PATCH] Revert "Removes unnecessary history.pushState if the welcome page is disabled and the user enter the base URL" This reverts commit 3d5af92c7ac78091d02b3f00fa8f4a7b47e804fc. --- app.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app.js b/app.js index 12f6a978a..6778fd109 100644 --- a/app.js +++ b/app.js @@ -24,6 +24,24 @@ import API from './modules/API/API'; import UIEvents from './service/UI/UIEvents'; +/** + * Tries to push history state with the following parameters: + * 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns + * it. + */ +function pushHistoryState(roomName, URL) { + try { + window.history.pushState( + 'VideoChat', `Room: ${roomName}`, URL + ); + } catch (e) { + console.warn("Push history state failed with parameters:", + 'VideoChat', `Room: ${roomName}`, URL, e); + return e; + } + return null; +} + /** * Builds and returns the room name. */ @@ -33,6 +51,14 @@ function buildRoomName () { if(!roomName) { let word = RoomnameGenerator.generateRoomWithoutSeparator(); roomName = word.toLowerCase(); + let historyURL = window.location.pathname + word; + //Trying to push state with URL "/" + roomName + var err = pushHistoryState(word, historyURL); + //If URL "/" + roomName is not good, trying with explicitly adding the + //domain name. + if(err && config.hosts.domain) { + pushHistoryState(word, "//" + config.hosts.domain + historyURL); + } } return roomName;