You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Add setIdentityServerUrl
Hopefully fairly self explanatory. The ID server URL can be changed fairly readily, whereas the HS URL would require a different access token etc.
This commit is contained in:
@@ -117,6 +117,15 @@ MatrixBaseApis.prototype.getIdentityServerUrl = function(stripProto=false) {
|
|||||||
return this.idBaseUrl;
|
return this.idBaseUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Identity Server URL of this client
|
||||||
|
* @param {string} url New Identity Server URL
|
||||||
|
*/
|
||||||
|
MatrixBaseApis.prototype.setIdentityServerUrl = function(url) {
|
||||||
|
this.idBaseUrl = utils.ensureNoTrailingSlash(url);
|
||||||
|
this._http.setIdBaseUrl(this._idBaseUrl);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the access token associated with this account.
|
* Get the access token associated with this account.
|
||||||
* @return {?String} The access_token or null
|
* @return {?String} The access_token or null
|
||||||
|
|||||||
@@ -161,15 +161,8 @@ function keyFromRecoverySession(session, decryptionKey) {
|
|||||||
* implements the {$link module:crypto/verification/Base verifier interface}.
|
* implements the {$link module:crypto/verification/Base verifier interface}.
|
||||||
*/
|
*/
|
||||||
function MatrixClient(opts) {
|
function MatrixClient(opts) {
|
||||||
// Allow trailing slash in HS url
|
opts.baseUrl = utils.ensureNoTrailingSlash(opts.baseUrl);
|
||||||
if (opts.baseUrl && opts.baseUrl.endsWith("/")) {
|
opts.idBaseUrl = utils.ensureNoTrailingSlash(opts.idBaseUrl);
|
||||||
opts.baseUrl = opts.baseUrl.substr(0, opts.baseUrl.length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow trailing slash in IS url
|
|
||||||
if (opts.idBaseUrl && opts.idBaseUrl.endsWith("/")) {
|
|
||||||
opts.idBaseUrl = opts.idBaseUrl.substr(0, opts.idBaseUrl.length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
MatrixBaseApis.call(this, opts);
|
MatrixBaseApis.call(this, opts);
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ module.exports.MatrixHttpApi = function MatrixHttpApi(event_emitter, opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.MatrixHttpApi.prototype = {
|
module.exports.MatrixHttpApi.prototype = {
|
||||||
|
/**
|
||||||
|
* Sets the baase URL for the identity server
|
||||||
|
* @param {string} url The new base url
|
||||||
|
*/
|
||||||
|
setIdBaseUrl: function(url) {
|
||||||
|
this.opts.idBaseUrl = url;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the content repository url with query parameters.
|
* Get the content repository url with query parameters.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -699,3 +700,11 @@ module.exports.globToRegexp = function(glob, extended) {
|
|||||||
}
|
}
|
||||||
return pat;
|
return pat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.ensureNoTrailingSlash = function(url) {
|
||||||
|
if (url && url.endsWith("/")) {
|
||||||
|
return url.substr(0, url.length - 1);
|
||||||
|
} else {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user