Skip to content

Commit 6aa4b70

Browse files
committed
Support --with-forwarding preconfiguration argument
1 parent dafb513 commit 6aa4b70

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ const amMainInstance = app.requestSingleInstanceLock();
9090
if (!amMainInstance) {
9191
app.quit();
9292
} else {
93+
const cliArgs = process.argv.slice(1);
94+
9395
app.on('ready', () => {
9496
Menu.setApplicationMenu(menu);
9597
});
@@ -151,6 +153,18 @@ if (!amMainInstance) {
151153
window.httpToolkitDesktopVersion = '${packageJson.version}';
152154
window.postMessage({ httpToolkitDesktopVersion: window.httpToolkitDesktopVersion }, '*');
153155
`);
156+
157+
if (cliArgs[0] === '--with-forwarding') {
158+
if (!cliArgs[1] || !cliArgs[1].includes('|') || cliArgs[1].match(/'"\n/)) {
159+
console.error('Invalid --with-forwarding argument');
160+
app.quit(1);
161+
} else {
162+
contents.executeJavaScript(`
163+
window.httpToolkitForwardingDefault = '${cliArgs[1]}';
164+
window.postMessage({ httpToolkitForwardingDefault: window.httpToolkitForwardingDefault }, '*');
165+
`);
166+
}
167+
}
154168
});
155169

156170
// Redirect all navigations & new windows to the system browser

0 commit comments

Comments
 (0)