Add appId as needed to local dapps

This commit is contained in:
Jaco Greeff 2017-11-20 13:37:52 +01:00
parent d8e86cfe0a
commit ac722e9e50
2 changed files with 25 additions and 4 deletions

View File

@ -110,7 +110,10 @@ export default class Dapp extends Component {
switch (app.type) {
case 'local':
src = `${dappsUrl}/${app.id}/`;
console.log('app', app);
src = app.localUrl
? `${app.localUrl}?appId=${app.id}`
: `${dappsUrl}/${app.id}/`;
break;
case 'network':

View File

@ -20,11 +20,29 @@ import Web3 from 'web3';
import web3extensions from './web3.extensions';
function initProvider () {
const parts = window.location.pathname.split('/');
let appId = parts[1];
const path = window.location.pathname.split('/');
const qs = ((query) => {
if (!query) {
return {};
}
return query.split('&').reduce((result, combined) => {
const [name, value] = combined.split('=', 2);
result[name] = !name
? ''
: decodeURIComponent(value.replace(/\+/g, ' '));
return result;
}, {});
})(window.location.search.substr(1));
let appId = path[1] || qs.appId;
console.log('appId', appId, path, qs);
if (appId === 'dapps') {
appId = parts[2];
appId = path[2];
} else if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId);
}