|
1 | 1 | /* |
2 | 2 | Copyright 2015, 2016 OpenMarket Ltd |
| 3 | +Copyright 2017 Vector Creations Ltd |
3 | 4 |
|
4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 6 | you may not use this file except in compliance with the License. |
@@ -147,16 +148,30 @@ var onNewScreen = function(screen) { |
147 | 148 | // If we're in electron, we should never pass through a file:// URL otherwise |
148 | 149 | // the identity server will try to 302 the browser to it, which breaks horribly. |
149 | 150 | // so in that instance, hardcode to use riot.im/app for now instead. |
150 | | -var makeRegistrationUrl = function() { |
| 151 | +var makeRegistrationUrl = function(params) { |
| 152 | + let url; |
151 | 153 | if (window.location.protocol === "file:") { |
152 | | - return 'https://riot.im/app/#/register'; |
| 154 | + url = 'https://riot.im/app/#/register'; |
| 155 | + } else { |
| 156 | + url = ( |
| 157 | + window.location.protocol + '//' + |
| 158 | + window.location.host + |
| 159 | + window.location.pathname + |
| 160 | + '#/register' |
| 161 | + ); |
153 | 162 | } |
154 | | - else { |
155 | | - return window.location.protocol + '//' + |
156 | | - window.location.host + |
157 | | - window.location.pathname + |
158 | | - '#/register'; |
| 163 | + |
| 164 | + const keys = Object.keys(params); |
| 165 | + for (let i = 0; i < keys.length; ++i) { |
| 166 | + if (i == 0) { |
| 167 | + url += '?'; |
| 168 | + } else { |
| 169 | + url += '&'; |
| 170 | + } |
| 171 | + const k = keys[i]; |
| 172 | + url += k + '=' + encodeURIComponent(params[k]); |
159 | 173 | } |
| 174 | + return url; |
160 | 175 | } |
161 | 176 |
|
162 | 177 | window.addEventListener('hashchange', onHashChange); |
@@ -258,7 +273,7 @@ async function loadApp() { |
258 | 273 | window.matrixChat = ReactDOM.render( |
259 | 274 | <MatrixChat |
260 | 275 | onNewScreen={onNewScreen} |
261 | | - registrationUrl={makeRegistrationUrl()} |
| 276 | + makeRegistrationUrl={makeRegistrationUrl} |
262 | 277 | ConferenceHandler={VectorConferenceHandler} |
263 | 278 | config={configJson} |
264 | 279 | realQueryParams={params} |
|
0 commit comments