2013-09-09 15:35:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# protocol
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-22 11:42:54 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								>  Register a custom protocol and intercept existing protocol requests.
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-23 11:20:56 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Process: [Main ](../glossary.md#main-process )
							 
						 
					
						
							
								
									
										
										
										
											2016-11-03 10:26:00 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								An example of implementing a protocol that has the same effect as the
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								`file://`  protocol:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-20 23:50:08 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { app, protocol, net } = require('electron')
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:59:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const path = require('node:path')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const url = require('node:url')
							 
						 
					
						
							
								
									
										
										
										
											2016-05-09 10:20:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-03 16:43:22 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								app.whenReady().then(() => {
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:59:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  protocol.handle('atom', (request) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const filePath = request.url.slice('atom://'.length)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return net.fetch(url.pathToFileURL(path.join(__dirname, filePath)).toString())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  })
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-09 10:20:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								**Note:** All methods unless specified can only be used after the `ready`  event
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								of the `app`  module gets emitted.
							 
						 
					
						
							
								
									
										
										
										
											2013-09-20 18:36:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## Using `protocol` with a custom `partition` or `session`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								A protocol is registered to a specific Electron [`session` ](./session.md )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								object. If you don't specify a session, then your `protocol`  will be applied to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								the default session that Electron uses. However, if you define a `partition`  or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`session`  on your `browserWindow` 's `webPreferences` , then that window will use
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								a different session and your custom protocol will not work if you just use
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`electron.protocol.XXX` .
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								To have your custom protocol work in combination with a custom session, you need
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								to register it to that session explicitly.
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-20 23:50:08 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 15:26:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { app, BrowserWindow, net, protocol, session } = require('electron')
							 
						 
					
						
							
								
									
										
										
										
											2023-08-30 08:55:23 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const path = require('node:path')
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const url = require('url')
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-03 16:43:22 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								app.whenReady().then(() => {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  const partition = 'persist:example'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  const ses = session.fromPartition(partition)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  ses.protocol.handle('atom', (request) => {
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 15:26:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const filePath = request.url.slice('atom://'.length)
							 
						 
					
						
							
								
									
										
										
										
											2024-05-13 16:59:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return net.fetch(url.pathToFileURL(path.resolve(__dirname, filePath)).toString())
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 15:26:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  const mainWindow = new BrowserWindow({ webPreferences: { partition } })
							 
						 
					
						
							
								
									
										
										
										
											2019-04-18 21:40:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## Methods
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The `protocol`  module has the following methods:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-30 12:54:18 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.registerSchemesAsPrivileged(customSchemes)`
 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-30 12:54:18 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `customSchemes`  [CustomScheme[]](structures/custom-scheme.md)
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 23:11:01 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								**Note:** This method can only be used before the `ready`  event of the `app` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								module gets emitted and can be called only once.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Registers the `scheme`  as standard, secure, bypasses content security policy for
							 
						 
					
						
							
								
									
										
										
										
											2023-12-06 11:22:41 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								resources, allows registering ServiceWorker, supports fetch API, streaming
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								video/audio, and V8 code cache. Specify a privilege with the value of `true`  to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								enable the capability.
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 23:11:01 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								An example of registering a privileged scheme, that bypasses Content Security
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Policy:
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 23:11:01 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-20 23:50:08 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 23:11:01 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { protocol } = require('electron')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								protocol.registerSchemesAsPrivileged([
							 
						 
					
						
							
								
									
										
										
										
											2019-01-30 12:54:18 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  { scheme: 'foo', privileges: { bypassCSP: true } }
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 23:11:01 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-29 11:41:15 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								A standard scheme adheres to what RFC 3986 calls [generic URI syntax ](https://tools.ietf.org/html/rfc3986#section-3 ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								For example `http`  and `https`  are standard schemes, while `file`  is not.
							 
						 
					
						
							
								
									
										
										
										
											2016-05-09 10:20:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Registering a scheme as standard allows relative and absolute resources to
							 
						 
					
						
							
								
									
										
										
										
											2016-05-09 10:20:08 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								be resolved correctly when served. Otherwise the scheme will behave like the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`file`  protocol, but without the ability to resolve relative URLs.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								For example when you load following page with custom protocol without
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								registering it as standard scheme, the image will not be loaded because
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								non-standard schemes can not recognize relative URLs:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< body > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < img  src = 'test.png' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / body > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2016-08-24 09:03:44 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Registering a scheme as standard will allow access to files through the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[FileSystem API][file-system-api]. Otherwise the renderer will throw a security
							 
						 
					
						
							
								
									
										
										
										
											2016-09-22 00:20:34 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								error for the scheme.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								By default web storage apis (localStorage, sessionStorage, webSQL, indexedDB,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cookies) are disabled for non standard schemes. So in general if you want to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								register a custom protocol to replace the `http`  protocol, you have to register
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								it as a standard scheme.
							 
						 
					
						
							
								
									
										
										
										
											2019-02-13 00:19:47 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-08 11:49:36 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Protocols that use streams (http and stream protocols) should set `stream: true` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The `<video>`  and `<audio>`  HTML elements expect protocols to buffer their
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								responses by default. The `stream`  flag configures those elements to correctly
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								expect streaming responses.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.handle(scheme, handler)`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  `scheme`  string - scheme to handle, for example `https`  or `my-app` . This is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  the bit before the `:`  in a URL.
							 
						 
					
						
							
								
									
										
										
										
											2024-03-25 03:19:44 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function\<[GlobalResponse ](https://nodejs.org/api/globals.html#response ) | Promise\<GlobalResponse\>\>
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [GlobalRequest ](https://nodejs.org/api/globals.html#request )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Register a protocol handler for `scheme` . Requests made to URLs with this
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								scheme will delegate to this handler to determine what response should be sent.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Either a `Response`  or a `Promise<Response>`  can be returned.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 15:26:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { app, net, protocol } = require('electron')
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 10:23:52 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const path = require('node:path')
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 15:26:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { pathToFileURL } = require('url')
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								protocol.registerSchemesAsPrivileged([
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    scheme: 'app',
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    privileges: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      standard: true,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      secure: true,
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 15:26:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      supportFetchAPI: true
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								app.whenReady().then(() => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  protocol.handle('app', (req) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const { host, pathname } = new URL(req.url)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if (host === 'bundle') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if (pathname === '/') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return new Response('< h1 > hello, world< / h1 > ', {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          headers: { 'content-type': 'text/html' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      }
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 10:23:52 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // NB, this checks for paths that escape the bundle, e.g.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // app://bundle/../../secret_file.txt
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 10:23:52 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const pathToServe = path.resolve(__dirname, pathname)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const relativePath = path.relative(__dirname, pathToServe)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const isSafe = relativePath & &  !relativePath.startsWith('..') & &  !path.isAbsolute(relativePath)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if (!isSafe) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return new Response('bad', {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          status: 400,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          headers: { 'content-type': 'text/html' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return net.fetch(pathToFileURL(pathToServe).toString())
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } else if (host === 'api') {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return net.fetch('https://api.my-server.com/' + pathname, {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        method: req.method,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        headers: req.headers,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        body: req.body
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								See the MDN docs for [`Request` ](https://developer.mozilla.org/en-US/docs/Web/API/Request ) and [`Response` ](https://developer.mozilla.org/en-US/docs/Web/API/Response ) for more details.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### `protocol.unhandle(scheme)`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  `scheme`  string - scheme for which to remove the handler.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Removes a protocol handler registered with `protocol.handle` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### `protocol.isProtocolHandled(scheme)`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether `scheme`  is already handled.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### `protocol.registerFileProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (string | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully registered
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Registers a protocol of `scheme`  that will send a file as the response. The
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`handler`  will be called with `request`  and `callback`  where `request`  is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								an incoming request for the `scheme` .
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								To handle the `request` , the `callback`  should be called with either the file's
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								path or an object that has a `path`  property, e.g. `callback(filePath)`  or
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`callback({ path: filePath })` . The `filePath`  must be an absolute path.
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								By default the `scheme`  is treated like `http:` , which is parsed differently
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								from protocols that follow the "generic URI syntax" like `file:` .
							 
						 
					
						
							
								
									
										
										
										
											2015-07-16 06:32:09 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.registerBufferProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (Buffer | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully registered
							 
						 
					
						
							
								
									
										
										
										
											2015-06-12 13:28:23 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-28 18:59:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Registers a protocol of `scheme`  that will send a `Buffer`  as a response.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The usage is the same with `registerFileProtocol` , except that the `callback` 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								should be called with either a `Buffer`  object or an object that has the `data` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								property.
							 
						 
					
						
							
								
									
										
										
										
											2015-06-12 13:28:23 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Example:
							 
						 
					
						
							
								
									
										
										
										
											2015-07-16 06:32:09 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-20 23:50:08 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2016-05-04 11:59:02 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								protocol.registerBufferProtocol('atom', (request, callback) => {
							 
						 
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  callback({ mimeType: 'text/html', data: Buffer.from('< h5 > Response< / h5 > ') })
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-06-12 13:28:23 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.registerStringProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (string | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully registered
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Registers a protocol of `scheme`  that will send a `string`  as a response.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-28 18:59:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The usage is the same with `registerFileProtocol` , except that the `callback` 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								should be called with either a `string`  or an object that has the `data` 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								property.
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.registerHttpProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 00:15:09 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  [ProtocolResponse ](structures/protocol-response.md )
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully registered
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Registers a protocol of `scheme`  that will send an HTTP request as a response.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-28 18:59:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The usage is the same with `registerFileProtocol` , except that the `callback` 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								should be called with an object that has the `url`  property.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-28 18:59:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.registerStreamProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (ReadableStream | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully registered
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Registers a protocol of `scheme`  that will send a stream as a response.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The usage is the same with `registerFileProtocol` , except that the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`callback`  should be called with either a [`ReadableStream` ](https://nodejs.org/api/stream.html#stream_class_stream_readable ) object or an object that
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								has the `data`  property.
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-20 23:50:08 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { protocol } = require('electron')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const { PassThrough } = require('stream')
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function createStream (text) {
							 
						 
					
						
							
								
									
										
										
										
											2017-11-29 11:58:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  const rv = new PassThrough() // PassThrough is also a Readable stream
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  rv.push(text)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  rv.push(null)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return rv
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								protocol.registerStreamProtocol('atom', (request, callback) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  callback({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    statusCode: 200,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    headers: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      'content-type': 'text/html'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    data: createStream('< h5 > Response< / h5 > ')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								It is possible to pass any object that implements the readable stream API (emits
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`data` /`end` /`error`  events). For example, here's how a file could be returned:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-20 23:50:08 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								protocol.registerStreamProtocol('atom', (request, callback) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  callback(fs.createReadStream('index.html'))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.unregisterProtocol(scheme)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully unregistered
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Unregisters the custom protocol of `scheme` .
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.isProtocolRegistered(scheme)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-17 09:05:10 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2019-01-17 09:05:10 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether `scheme`  is already registered.
							 
						 
					
						
							
								
									
										
										
										
											2019-01-17 09:05:10 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.interceptFileProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (string | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully intercepted
							 
						 
					
						
							
								
									
										
										
										
											2013-09-03 18:22:40 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Intercepts `scheme`  protocol and uses `handler`  as the protocol's new handler
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								which sends a file as a response.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-16 18:23:45 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.interceptStringProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-16 18:23:45 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (string | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully intercepted
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Intercepts `scheme`  protocol and uses `handler`  as the protocol's new handler
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								which sends a `string`  as a response.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-16 18:23:45 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.interceptBufferProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-07 13:12:35 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (Buffer | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully intercepted
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 11:32:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Intercepts `scheme`  protocol and uses `handler`  as the protocol's new handler
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								which sends a `Buffer`  as a response.
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 11:32:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.interceptHttpProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 11:32:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  [ProtocolResponse ](structures/protocol-response.md )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully intercepted
							 
						 
					
						
							
								
									
										
										
										
											2015-05-07 13:12:35 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-28 22:03:39 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Intercepts `scheme`  protocol and uses `handler`  as the protocol's new handler
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								which sends a new HTTP request as a response.
							 
						 
					
						
							
								
									
										
										
										
											2015-05-07 13:12:35 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.interceptStreamProtocol(scheme, handler)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `handler`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 08:18:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `request`  [ProtocolRequest ](structures/protocol-request.md )
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  *  `callback`  Function
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    *  `response`  (ReadableStream | [ProtocolResponse ](structures/protocol-response.md ))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully intercepted
							 
						 
					
						
							
								
									
										
										
										
											2017-11-10 13:21:09 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Same as `protocol.registerStreamProtocol` , except that it replaces an existing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								protocol handler.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.uninterceptProtocol(scheme)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-07 13:12:35 +05:30 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether the protocol was successfully unintercepted
							 
						 
					
						
							
								
									
										
										
										
											2016-10-13 17:30:57 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-14 13:44:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Remove the interceptor installed for `scheme`  and restore its original handler.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-28 18:59:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-27 10:00:55 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### `protocol.isProtocolIntercepted(scheme)` _Deprecated_
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								*  `scheme`  string
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-16 05:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Returns `boolean`  - Whether `scheme`  is already intercepted.
							 
						 
					
						
							
								
									
										
										
										
											2020-06-02 09:46:18 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-24 09:03:44 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[file-system-api]: https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem