forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customProtocols.js
45 lines (37 loc) · 1.23 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
38
39
40
41
42
43
44
45
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'