Created
March 15, 2024 00:31
-
-
Save jmercouris/5682e62e11b73c8b2e99c303d51eacd0 to your computer and use it in GitHub Desktop.
test_scheme.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, net, protocol, BrowserWindow } = require('electron') | |
const path = require('path') | |
const { pathToFileURL } = require('url') | |
protocol.registerSchemesAsPrivileged([ | |
{ | |
scheme: 'a', | |
privileges: { | |
standard: true | |
} | |
} | |
]); | |
protocol.registerSchemesAsPrivileged([ | |
{ | |
scheme: 'b', | |
privileges: { | |
standard: false | |
} | |
} | |
]); | |
app.whenReady().then(() => { | |
protocol.handle('a', (req) => { | |
const { host, pathname } = new URL(req.url); | |
return new Response('<p>Hello</p>', { | |
headers: { 'content-type': 'text/html' } | |
}) | |
}) | |
}); | |
app.whenReady().then(() => { | |
protocol.handle('b', (req) => { | |
const { host, pathname } = new URL(req.url); | |
return new Response('<p>world</p>', { | |
headers: { 'content-type': 'text/html' } | |
}) | |
}) | |
}); | |
function createWindow() { | |
const aWindow = new BrowserWindow() | |
aWindow.loadURL('a:') | |
const bWindow = new BrowserWindow() | |
bWindow.loadURL('b:') | |
} | |
app.whenReady().then(() => { | |
createWindow() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment