1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-09 10:22:46 +03:00

Merge branches 'develop' and 't3chguy/remove_bluebird_12' of github.com:matrix-org/matrix-js-sdk into t3chguy/remove_bluebird_12

This commit is contained in:
Michael Telatynski
2019-12-04 23:44:04 +00:00
2 changed files with 14 additions and 6 deletions

View File

@@ -623,7 +623,9 @@ describe("Room", function() {
}; };
const setAliases = function(aliases, stateKey) { const setAliases = function(aliases, stateKey) {
if (!stateKey) { if (!stateKey) {
stateKey = "flibble"; stateKey = aliases.length
? aliases[0].split(':').splice(1).join(':') // domain+port
: 'fibble';
} }
room.addLiveEvents([utils.mkEvent({ room.addLiveEvents([utils.mkEvent({
type: "m.room.aliases", room: roomId, skey: stateKey, content: { type: "m.room.aliases", room: roomId, skey: stateKey, content: {
@@ -864,7 +866,7 @@ describe("Room", function() {
"(invite join_rules) rooms if a room name doesn't exist.", function() { "(invite join_rules) rooms if a room name doesn't exist.", function() {
const alias = "#room_alias:here"; const alias = "#room_alias:here";
setJoinRule("invite"); setJoinRule("invite");
setAliases([alias, "#another:one"]); setAliases([alias, "#another:here"]);
room.recalculate(); room.recalculate();
const name = room.name; const name = room.name;
expect(name).toEqual(alias); expect(name).toEqual(alias);
@@ -874,7 +876,7 @@ describe("Room", function() {
"(public join_rules) rooms if a room name doesn't exist.", function() { "(public join_rules) rooms if a room name doesn't exist.", function() {
const alias = "#room_alias:here"; const alias = "#room_alias:here";
setJoinRule("public"); setJoinRule("public");
setAliases([alias, "#another:one"]); setAliases([alias, "#another:here"]);
room.recalculate(); room.recalculate();
const name = room.name; const name = room.name;
expect(name).toEqual(alias); expect(name).toEqual(alias);

View File

@@ -839,9 +839,15 @@ Room.prototype.getAliases = function() {
for (let i = 0; i < aliasEvents.length; ++i) { for (let i = 0; i < aliasEvents.length; ++i) {
const aliasEvent = aliasEvents[i]; const aliasEvent = aliasEvents[i];
if (utils.isArray(aliasEvent.getContent().aliases)) { if (utils.isArray(aliasEvent.getContent().aliases)) {
Array.prototype.push.apply( const filteredAliases = aliasEvent.getContent().aliases.filter(a => {
aliasStrings, aliasEvent.getContent().aliases, if (typeof(a) !== "string") return false;
); if (a[0] !== '#') return false;
if (!a.endsWith(`:${aliasEvent.getStateKey()}`)) return false;
// It's probably valid by here.
return true;
});
Array.prototype.push.apply(aliasStrings, filteredAliases);
} }
} }
} }