You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-31 13:44:28 +03:00
Add 'getHomeServerName' util to client peg
This commit is contained in:
@ -85,6 +85,19 @@ class MatrixClientPeg {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the server name of the user's home server
|
||||
* Throws an error if unable to deduce the home server name
|
||||
* (eg. if the user is not logged in)
|
||||
*/
|
||||
getHomeServerName() {
|
||||
const matches = /^@.+:(.+)$/.exec(this.matrixClient.credentials.userId);
|
||||
if (matches === null || matches.length < 1) {
|
||||
throw new Error("Failed to derive home server name fro user ID!");
|
||||
}
|
||||
return matches[1];
|
||||
}
|
||||
|
||||
_createClient(creds: MatrixClientCreds) {
|
||||
var opts = {
|
||||
baseUrl: creds.homeserverUrl,
|
||||
|
Reference in New Issue
Block a user