forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
customProtocols.js
42 lines (27 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
const electron = require('electron');
const protocol = electron.protocol;
const path = require('path');
protocol.registerHttpProtocol('mist', function(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','') : '');
var 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);
}, function (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'