fix ssh url handling

This commit is contained in:
Labhansh Agrawal 2023-05-06 10:22:45 +05:30
parent 32447ade1b
commit 32eeb6d0cf
6 changed files with 8 additions and 12 deletions

View file

@ -253,11 +253,11 @@
"type": "string" "type": "string"
}, },
"shell": { "shell": {
"description": "the shell to run when spawning a new session (i.e. /usr/local/bin/fish)\nif left empty, your system's login shell will be used by default\n\nWindows\n- Make sure to use a full path if the binary name doesn't work\n- Remove `--login` in shellArgs\n\nWindows Subsystem for Linux (WSL) - previously Bash on Windows\n- Example: `C:\\\\Windows\\\\System32\\\\wsl.exe`\n\nGit-bash on Windows\n- Example: `C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe`\n\nPowerShell on Windows\n- Example: `C:\\\\WINDOWS\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`\n\nCygwin\n- Example: `C:\\\\cygwin64\\\\bin\\\\bash.exe`\n\nGit Bash\n- Example: `C:\\\\Program Files\\\\Git\\\\git-cmd.exe`\nThen Add `--command=usr/bin/bash.exe` to shellArgs", "description": "the shell to run when spawning a new session (e.g. /usr/local/bin/fish)\nif left empty, your system's login shell will be used by default\n\nWindows\n- Make sure to use a full path if the binary name doesn't work\n- Remove `--login` in shellArgs\n\nWindows Subsystem for Linux (WSL) - previously Bash on Windows\n- Example: `C:\\\\Windows\\\\System32\\\\wsl.exe`\n\nGit-bash on Windows\n- Example: `C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe`\n\nPowerShell on Windows\n- Example: `C:\\\\WINDOWS\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`\n\nCygwin\n- Example: `C:\\\\cygwin64\\\\bin\\\\bash.exe`\n\nGit Bash\n- Example: `C:\\\\Program Files\\\\Git\\\\git-cmd.exe`\nThen Add `--command=usr/bin/bash.exe` to shellArgs",
"type": "string" "type": "string"
}, },
"shellArgs": { "shellArgs": {
"description": "for setting shell arguments (i.e. for using interactive shellArgs: `['-i']`)\nby default `['--login']` will be used", "description": "for setting shell arguments (e.g. for using interactive shellArgs: `['-i']`)\nby default `['--login']` will be used",
"items": { "items": {
"type": "string" "type": "string"
}, },

View file

@ -31,6 +31,7 @@ import {installCLI} from './utils/cli-install';
import * as AppMenu from './menus/menu'; import * as AppMenu from './menus/menu';
import {newWindow} from './ui/window'; import {newWindow} from './ui/window';
import * as windowUtils from './utils/window-utils'; import * as windowUtils from './utils/window-utils';
import parseUrl from 'parse-url';
const windowSet = new Set<BrowserWindow>([]); const windowSet = new Set<BrowserWindow>([]);
@ -234,6 +235,6 @@ app.on('open-file', (_event, path) => {
app.on('open-url', (_event, sshUrl) => { app.on('open-url', (_event, sshUrl) => {
GetWindow((win: BrowserWindow) => { GetWindow((win: BrowserWindow) => {
win.rpc.emit('open ssh', sshUrl); win.rpc.emit('open ssh', parseUrl(sshUrl));
}); });
}); });

View file

@ -292,12 +292,11 @@ export function leaveFullScreen(): HyperActions {
}; };
} }
export function openSSH(url: string) { export function openSSH(parsedUrl: ReturnType<typeof parseUrl>) {
return (dispatch: HyperDispatch) => { return (dispatch: HyperDispatch) => {
dispatch({ dispatch({
type: UI_OPEN_SSH_URL, type: UI_OPEN_SSH_URL,
effect() { effect() {
const parsedUrl = parseUrl(url, true);
let command = `${parsedUrl.protocol} ${parsedUrl.user ? `${parsedUrl.user}@` : ''}${parsedUrl.resource}`; let command = `${parsedUrl.protocol} ${parsedUrl.user ? `${parsedUrl.user}@` : ''}${parsedUrl.resource}`;
if (parsedUrl.port) command += ` -p ${parsedUrl.port}`; if (parsedUrl.port) command += ` -p ${parsedUrl.port}`;

View file

@ -2,10 +2,6 @@ declare module 'php-escape-shell' {
export function php_escapeshellcmd(path: string): string; export function php_escapeshellcmd(path: string): string;
} }
declare module 'parse-url' {
export default function (...args: any[]): any;
}
declare module 'react-deep-force-update' { declare module 'react-deep-force-update' {
export default function (...args: any[]): any; export default function (...args: any[]): any;
} }

View file

@ -204,8 +204,8 @@ rpc.on('open file', ({path}) => {
store_.dispatch(uiActions.openFile(path)); store_.dispatch(uiActions.openFile(path));
}); });
rpc.on('open ssh', (url) => { rpc.on('open ssh', (parsedUrl) => {
store_.dispatch(uiActions.openSSH(url)); store_.dispatch(uiActions.openSSH(parsedUrl));
}); });
rpc.on('update available', ({releaseName, releaseNotes, releaseUrl, canInstall}) => { rpc.on('update available', ({releaseName, releaseNotes, releaseUrl, canInstall}) => {

View file

@ -42,7 +42,6 @@
"ms": "2.1.3", "ms": "2.1.3",
"open": "8.4.2", "open": "8.4.2",
"ora": "5.4.1", "ora": "5.4.1",
"parse-url": "8.1.0",
"php-escape-shell": "1.0.0", "php-escape-shell": "1.0.0",
"react": "17.0.2", "react": "17.0.2",
"react-deep-force-update": "2.1.3", "react-deep-force-update": "2.1.3",
@ -122,6 +121,7 @@
"node-addon-api": "6.1.0", "node-addon-api": "6.1.0",
"node-gyp": "9.3.1", "node-gyp": "9.3.1",
"null-loader": "4.0.1", "null-loader": "4.0.1",
"parse-url": "8.1.0",
"playwright": "1.33.0", "playwright": "1.33.0",
"plist": "3.0.6", "plist": "3.0.6",
"prettier": "2.8.8", "prettier": "2.8.8",