forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
customProtocols.js
37 lines (26 loc) · 1.18 KB
/
customProtocols.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { protocol } = require('electron');
protocol.registerHttpProtocol('mist', (request, callback) => {
// callback({mimeType: 'text/html', data: new Buffer('<h5>Response</h5>')});
console.log((request.url.indexOf('mist://interface') !== -1) ? global.interfaceAppUrl + request.url.replace('mist://interface', '') : '');
const call = {
url: (request.url.indexOf('mist://interface') !== -1) ? global.interfaceAppUrl + request.url.replace('mist://interface', '') : '', // 'http://localhost:3050/' + request.url.replace('mist://',''),
method: request.method,
referrer: request.referrer,
};
console.log(call);
// console.log(call);
callback(call);
}, (error) => {
if (error) {
console.error('Failed to register protocol');
}
});
// protocol.registerProtocol('eth', function(request) {
// var url = request.url.substr(7)
// return new protocol.RequestStringJob({data: 'Hello'});
// });
// protocol.registerProtocol('bzz', function(request) {
// var url = request.url.substr(7)
// return new protocol.RequestStringJob({data: 'Hello'});
// });
// protocol.registerStandardSchemes(['mist','eth', 'bzz']); //'eth', 'bzz'