mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Use node querystring module to parse query string like name value pairs from fragment
This commit is contained in:
parent
353af6c647
commit
f5039ac9af
@ -21,21 +21,20 @@ var sdk = require("matrix-react-sdk");
|
||||
sdk.loadSkin(require('../skins/vector/skindex'));
|
||||
sdk.loadModule(require('../modules/VectorConferenceHandler'));
|
||||
|
||||
var qs = require("querystring");
|
||||
|
||||
var lastLocationHashSet = null;
|
||||
|
||||
|
||||
function parseQueryParams(location) {
|
||||
// We want to support some name / value pairs in the fragment
|
||||
// so we're re-using query string ike format
|
||||
function parseQsFromFragment(location) {
|
||||
var hashparts = location.hash.split('?');
|
||||
var params = {};
|
||||
if (hashparts.length == 2) {
|
||||
var pairs = hashparts[1].split('&');
|
||||
for (var i = 0; i < pairs.length; ++i) {
|
||||
var parts = pairs[i].split('=');
|
||||
if (parts.length != 2) continue;
|
||||
params[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
|
||||
}
|
||||
if (hashparts.length > 1) {
|
||||
console.log(qs.parse(hashparts[1]));
|
||||
return qs.parse(hashparts[1]);
|
||||
}
|
||||
return params
|
||||
return {};
|
||||
}
|
||||
|
||||
// Here, we do some crude URL analysis to allow
|
||||
@ -43,9 +42,9 @@ function parseQueryParams(location) {
|
||||
// deep-links in this example.
|
||||
function routeUrl(location) {
|
||||
if (location.hash.indexOf('#/register') == 0) {
|
||||
window.matrixChat.showScreen('register', parseQueryParams(location));
|
||||
window.matrixChat.showScreen('register', parseQsFromFragment(location));
|
||||
} else if (location.hash.indexOf('#/login/cas') == 0) {
|
||||
window.matrixChat.showScreen('cas_login', parseQueryParams(location));
|
||||
window.matrixChat.showScreen('cas_login', parseQsFromFragment(location));
|
||||
} else {
|
||||
window.matrixChat.showScreen(location.hash.substring(2));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user