Skip to content

Commit a8e3da8

Browse files
committed
Support --with-forwarding preconfiguration argument
1 parent f5f493d commit a8e3da8

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
@@ -103,6 +103,18 @@ if (!amMainInstance) {
103103
console.log('Not the main instance - quitting');
104104
app.quit();
105105
} else {
106+
const cliArgs = process.argv.slice(1);
107+
108+
let forwardingUrl: string | undefined = undefined;
109+
if (cliArgs[0] === '--with-forwarding') {
110+
if (!cliArgs[1] || !cliArgs[1].includes('|') || cliArgs[1].match(/'"\n/)) {
111+
console.error('Invalid --with-forwarding argument');
112+
process.exit(1); // Safe to hard exit - we haven't opened/started anything yet.
113+
} else {
114+
forwardingUrl = cliArgs[1];
115+
}
116+
}
117+
106118
app.on('ready', () => {
107119
Menu.setApplicationMenu(menu);
108120
});
@@ -180,6 +192,8 @@ if (!amMainInstance) {
180192
// gets replaced on first navigation (immediately), whilst global
181193
// vars like this are forever.
182194
injectValue('httpToolkitAuthToken', AUTH_TOKEN);
195+
196+
if (forwardingUrl) injectValue('httpToolkitForwardingDefault', forwardingUrl);
183197
});
184198

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

0 commit comments

Comments
 (0)