diff --git a/src/vector/index.js b/src/vector/index.js index 8a6a3448..1be71052 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -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)); }