diff --git a/src/components/CreateRoom.vue b/src/components/CreateRoom.vue
index efc0ec2..a87b0bd 100644
--- a/src/components/CreateRoom.vue
+++ b/src/components/CreateRoom.vue
@@ -295,7 +295,7 @@ export default {
}
if (room) {
this.publicRoomLink = this.$router.getRoomLink(
- room.getCanonicalAlias() || roomId
+ room.getCanonicalAlias(), roomId, room.name
);
}
});
diff --git a/src/components/Join.vue b/src/components/Join.vue
index e35d8b1..c5548d5 100644
--- a/src/components/Join.vue
+++ b/src/components/Join.vue
@@ -13,7 +13,7 @@
{{ roomId && roomId.startsWith("@") ? $t("join.title_user") : $t("join.title") }}
- {{ roomName }}
+ {{ roomDisplayName || roomName }}
@@ -215,6 +215,14 @@ export default {
let activeLanguages = [...this.getLanguages()];
return activeLanguages.filter((lang) => lang.value === this.$i18n.locale);
},
+ roomDisplayName() {
+ // If there is a display name in to invite link, use that!
+ try {
+ return new URL(location.href).searchParams.get('roomName');
+ } catch(ignoredError) {
+ return undefined;
+ }
+ }
},
watch: {
roomId: {
diff --git a/src/components/roomInfoMixin.js b/src/components/roomInfoMixin.js
index cb420f5..53cb205 100644
--- a/src/components/roomInfoMixin.js
+++ b/src/components/roomInfoMixin.js
@@ -57,7 +57,7 @@ export default {
publicRoomLink() {
if (this.room && this.roomJoinRule == "public") {
return this.$router.getRoomLink(
- this.room.getCanonicalAlias() || this.room.roomId
+ this.room.getCanonicalAlias(), this.room.roomId, this.room.name
);
}
return null;
diff --git a/src/plugins/utils.js b/src/plugins/utils.js
index 873b126..898e93e 100644
--- a/src/plugins/utils.js
+++ b/src/plugins/utils.js
@@ -778,6 +778,13 @@ class Util {
return _browserCanRecordAudio;
}
+ getRoomNameFromAlias(alias) {
+ if (alias && alias.startsWith('#') && alias.indexOf(':') > 0) {
+ return alias.slice(1).split(':')[0];
+ }
+ return undefined;
+ }
+
getUniqueAliasForRoomName(matrixClient, roomName, homeServer, iterationCount) {
return new Promise((resolve, reject) => {
var preferredAlias = roomName.replace(/\s/g, "").toLowerCase();
diff --git a/src/router/index.js b/src/router/index.js
index 1599551..7c85163 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -140,8 +140,13 @@ router.beforeEach((to, from, next) => {
}
});
-router.getRoomLink = function (roomId) {
- return window.location.origin + window.location.pathname + "#/room/" + encodeURIComponent(util.sanitizeRoomId(roomId));
+router.getRoomLink = function (alias, roomId, roomName) {
+ if ((!alias || roomName.replace(/\s/g, "").toLowerCase() !== util.getRoomNameFromAlias(alias)) && roomName) {
+ // There is no longer a correlation between alias and room name, probably because room name has
+ // changed. Include the "?roomName" part
+ return window.location.origin + window.location.pathname + "?roomName=" + encodeURIComponent(roomName) + "#/room/" + encodeURIComponent(util.sanitizeRoomId(alias || roomId));
+ }
+ return window.location.origin + window.location.pathname + "#/room/" + encodeURIComponent(util.sanitizeRoomId(alias || roomId));
}
export default router