summary refs log tree commit diff
path: root/webclient/room/room-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'webclient/room/room-controller.js')
-rw-r--r--webclient/room/room-controller.js42
1 files changed, 27 insertions, 15 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 999c48f02d..d130a28fd7 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -109,8 +109,8 @@ angular.module('RoomController', ['ngSanitize'])
    'use strict';
     var MESSAGES_PER_PAGINATION = 30;
 
-    // Room ids. Checked, computed and resolved in onInit
-    $scope.room_id = $routeParams.room_id;
+    // Room ids. Computed and resolved in onInit
+    $scope.room_id = undefined;
     $scope.room_alias = undefined;
 
     $scope.state = {
@@ -347,27 +347,39 @@ angular.module('RoomController', ['ngSanitize'])
         console.log("onInit");
         
         // Does the room ID provided in the URL?
-        if ($scope.room_id) {
-            // Yes, we can start right now
+        var room_id_or_alias;
+        if ($routeParams.room_id_or_alias) {
+            room_id_or_alias = decodeURIComponent($routeParams.room_id_or_alias);
+        }
+
+        if (room_id_or_alias && '!' === room_id_or_alias[0]) {
+            // Yes. We can start right now
+            $scope.room_id = room_id_or_alias;
             $scope.room_alias = matrixService.getRoomIdToAliasMapping($scope.room_id);
             onInit2();
         }
         else {
-            // No, the URL contains the room alias. Get this alias.
-            // ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080
-            if (3 === location.hash.split("#").length) {
-                $scope.room_alias = "#" + location.hash.split("#")[2];
+            // No. The URL contains the room alias. Get this alias.
+            if (room_id_or_alias) {
+                // The room alias was passed urlencoded, use it as is
+                $scope.room_alias = room_id_or_alias;
             }
-            else {
-                // In case of issue, go to the default page
-                console.log("Error: cannot extract room alias");
-                $location.path("/");
-                return;
+            else  {
+                // Else get the room alias by hand from the URL
+                // ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080
+                if (3 === location.hash.split("#").length) {
+                    $scope.room_alias = "#" + location.hash.split("#")[2];
+                }
+                else {
+                    // In case of issue, go to the default page
+                    console.log("Error: cannot extract room alias");
+                    $location.path("/");
+                    return;
+                }
             }
             
-            console.log("Resolving alias: " + $scope.room_alias);
-
             // Need a room ID required in Matrix API requests
+            console.log("Resolving alias: " + $scope.room_alias);
             matrixService.resolveRoomAlias($scope.room_alias).then(function(response) {
                 $scope.room_id = response.data.room_id;
                 console.log("   -> Room ID: " + $scope.room_id);