Skip to content

Commit

Permalink
fix ssh url handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LabhanshAgrawal committed May 6, 2023
1 parent 32447ad commit 32eeb6d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@
"type": "string"
},
"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"
},
"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": {
"type": "string"
},
Expand Down
3 changes: 2 additions & 1 deletion app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {installCLI} from './utils/cli-install';
import * as AppMenu from './menus/menu';
import {newWindow} from './ui/window';
import * as windowUtils from './utils/window-utils';
import parseUrl from 'parse-url';

const windowSet = new Set<BrowserWindow>([]);

Expand Down Expand Up @@ -234,6 +235,6 @@ app.on('open-file', (_event, path) => {

app.on('open-url', (_event, sshUrl) => {
GetWindow((win: BrowserWindow) => {
win.rpc.emit('open ssh', sshUrl);
win.rpc.emit('open ssh', parseUrl(sshUrl));
});
});
3 changes: 1 addition & 2 deletions lib/actions/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,11 @@ export function leaveFullScreen(): HyperActions {
};
}

export function openSSH(url: string) {
export function openSSH(parsedUrl: ReturnType<typeof parseUrl>) {
return (dispatch: HyperDispatch) => {
dispatch({
type: UI_OPEN_SSH_URL,
effect() {
const parsedUrl = parseUrl(url, true);
let command = `${parsedUrl.protocol} ${parsedUrl.user ? `${parsedUrl.user}@` : ''}${parsedUrl.resource}`;

if (parsedUrl.port) command += ` -p ${parsedUrl.port}`;
Expand Down
4 changes: 0 additions & 4 deletions lib/ext-modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ declare module 'php-escape-shell' {
export function php_escapeshellcmd(path: string): string;
}

declare module 'parse-url' {
export default function (...args: any[]): any;
}

declare module 'react-deep-force-update' {
export default function (...args: any[]): any;
}
4 changes: 2 additions & 2 deletions lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ rpc.on('open file', ({path}) => {
store_.dispatch(uiActions.openFile(path));
});

rpc.on('open ssh', (url) => {
store_.dispatch(uiActions.openSSH(url));
rpc.on('open ssh', (parsedUrl) => {
store_.dispatch(uiActions.openSSH(parsedUrl));
});

rpc.on('update available', ({releaseName, releaseNotes, releaseUrl, canInstall}) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"ms": "2.1.3",
"open": "8.4.2",
"ora": "5.4.1",
"parse-url": "8.1.0",
"php-escape-shell": "1.0.0",
"react": "17.0.2",
"react-deep-force-update": "2.1.3",
Expand Down Expand Up @@ -122,6 +121,7 @@
"node-addon-api": "6.1.0",
"node-gyp": "9.3.1",
"null-loader": "4.0.1",
"parse-url": "8.1.0",
"playwright": "1.33.0",
"plist": "3.0.6",
"prettier": "2.8.8",
Expand Down

0 comments on commit 32eeb6d

Please sign in to comment.