diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 8bc1fbdd07..b8d78fc447 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1887,6 +1887,7 @@ export default React.createClass({ sessionId={this.state.register_session_id} idSid={this.state.register_id_sid} email={this.props.startingFragmentQueryParams.email} + defaultServerName={this.getDefaultServerName()} defaultServerDiscoveryError={this.state.defaultServerDiscoveryError} defaultHsUrl={this.getDefaultHsUrl()} defaultIsUrl={this.getDefaultIsUrl()} diff --git a/src/components/structures/auth/Registration.js b/src/components/structures/auth/Registration.js index 04570df868..f3c6306f79 100644 --- a/src/components/structures/auth/Registration.js +++ b/src/components/structures/auth/Registration.js @@ -48,15 +48,20 @@ module.exports = React.createClass({ sessionId: PropTypes.string, makeRegistrationUrl: PropTypes.func.isRequired, idSid: PropTypes.string, + // The default server name to use when the user hasn't specified + // one. If set, `defaultHsUrl` and `defaultHsUrl` were derived for this + // via `.well-known` discovery. The server name is used instead of the + // HS URL when talking about "your account". + defaultServerName: PropTypes.string, + // An error passed along from higher up explaining that something + // went wrong when finding the defaultHsUrl. + defaultServerDiscoveryError: PropTypes.string, customHsUrl: PropTypes.string, customIsUrl: PropTypes.string, defaultHsUrl: PropTypes.string, defaultIsUrl: PropTypes.string, brand: PropTypes.string, email: PropTypes.string, - // An error passed along from higher up explaining that something - // went wrong when finding the defaultHsUrl. - defaultServerDiscoveryError: PropTypes.string, // registration shouldn't know or care how login is done. onLoginClick: PropTypes.func.isRequired, onServerConfigChange: PropTypes.func.isRequired, @@ -470,6 +475,14 @@ module.exports = React.createClass({ ) { onEditServerDetailsClick = this.onEditServerDetailsClick; } + + // If the current HS URL is the default HS URL, then we can label it + // with the default HS name (if it exists). + let hsName; + if (this.state.hsUrl === this.props.defaultHsUrl) { + hsName = this.props.defaultServerName; + } + return ; } diff --git a/src/components/views/auth/RegistrationForm.js b/src/components/views/auth/RegistrationForm.js index acde4d03fe..910c72ef47 100644 --- a/src/components/views/auth/RegistrationForm.js +++ b/src/components/views/auth/RegistrationForm.js @@ -50,6 +50,10 @@ module.exports = React.createClass({ onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise onEditServerDetailsClick: PropTypes.func, flows: PropTypes.arrayOf(PropTypes.object).isRequired, + // This is optional and only set if we used a server name to determine + // the HS URL via `.well-known` discovery. The server name is used + // instead of the HS URL when talking about "your account". + hsName: PropTypes.string, hsUrl: PropTypes.string, }, @@ -296,13 +300,19 @@ module.exports = React.createClass({ render: function() { let yourMatrixAccountText = _t('Create your account'); - try { - const parsedHsUrl = new URL(this.props.hsUrl); + if (this.props.hsName) { yourMatrixAccountText = _t('Create your %(serverName)s account', { - serverName: parsedHsUrl.hostname, + serverName: this.props.hsName, }); - } catch (e) { - // ignore + } else { + try { + const parsedHsUrl = new URL(this.props.hsUrl); + yourMatrixAccountText = _t('Create your %(serverName)s account', { + serverName: parsedHsUrl.hostname, + }); + } catch (e) { + // ignore + } } let editLink = null;