mirror of
https://github.com/electron/electron.git
synced 2026-01-10 07:58:08 -05:00
Updated example of implementing a protocol.
These changes demonstrates a more usable protocol implementation.
This commit is contained in:
@@ -7,10 +7,15 @@ An example of implementing a protocol that has the same effect with the
|
||||
`file://` protocol:
|
||||
|
||||
```javascript
|
||||
var protocol = require('protocol');
|
||||
protocol.registerProtocol('atom', function(request) {
|
||||
var path = request.url.substr(7)
|
||||
return new protocol.RequestFileJob(path);
|
||||
var app = require('app'),
|
||||
path = require('path');
|
||||
|
||||
app.on('will-finish-launching', function() {
|
||||
var protocol = require('protocol');
|
||||
protocol.registerProtocol('atom', function(request) {
|
||||
var url = request.url.substr(7)
|
||||
return new protocol.RequestFileJob(path.normalize(__dirname + '/' + url));
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user