Fix pills for CIDER too
This commit is contained in:
parent
2824f468d9
commit
ce0a534db1
6 changed files with 27 additions and 7 deletions
|
@ -35,6 +35,10 @@ export default class PermalinkConstructor {
|
|||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
forEntity(entityId: string): string {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
isPermalinkHost(host: string): boolean {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
|
|
@ -48,6 +48,16 @@ export default class RiotPermalinkConstructor extends PermalinkConstructor {
|
|||
return `${this._riotUrl}/#/group/${groupId}`;
|
||||
}
|
||||
|
||||
forEntity(entityId: string): string {
|
||||
if (entityId[0] === '!' || entityId[0] === '#') {
|
||||
return this.forRoom(entityId);
|
||||
} else if (entityId[0] === '@') {
|
||||
return this.forUser(entityId);
|
||||
} else if (entityId[0] === '+') {
|
||||
return this.forGroup(entityId);
|
||||
} else throw new Error("Unrecognized entity");
|
||||
}
|
||||
|
||||
isPermalinkHost(testHost: string): boolean {
|
||||
const parsedUrl = new URL(this._riotUrl);
|
||||
return testHost === (parsedUrl.host || parsedUrl.hostname); // one of the hosts should match
|
||||
|
|
|
@ -253,6 +253,10 @@ export class RoomPermalinkCreator {
|
|||
}
|
||||
}
|
||||
|
||||
export function makeGenericPermalink(entityId: string): string {
|
||||
return getPermalinkConstructor().forEntity(entityId);
|
||||
}
|
||||
|
||||
export function makeUserPermalink(userId) {
|
||||
return getPermalinkConstructor().forUser(userId);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ export default class SpecPermalinkConstructor extends PermalinkConstructor {
|
|||
return `${baseUrl}/#/${groupId}`;
|
||||
}
|
||||
|
||||
forEntity(entityId: string): string {
|
||||
return `${baseUrl}/#/${entityId}`;
|
||||
}
|
||||
|
||||
isPermalinkHost(testHost: string): boolean {
|
||||
return testHost === host;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue