mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
parent
25fcf3a6a4
commit
b2f67c73e4
3 changed files with 8 additions and 22 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import rpc from '../rpc';
|
||||
import getURL from '../utils/url-command';
|
||||
import isUrl from '../utils/url-command';
|
||||
import {keys} from '../utils/object';
|
||||
import findBySession from '../utils/term-groups';
|
||||
import {
|
||||
|
|
@ -56,7 +56,7 @@ export function addSessionData(uid, data) {
|
|||
const {shell} = getState().sessions.sessions[uid];
|
||||
|
||||
const enterKey = Boolean(data.match(/\n/));
|
||||
const url = enterKey ? getURL(shell, data) : null;
|
||||
const url = enterKey ? isUrl(shell, data) : null;
|
||||
|
||||
if (url) {
|
||||
dispatch({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import * as regex from './url-regex';
|
||||
|
||||
export const domainRegex = /([0-9]+[:.]*)+|([a-zA-Z0-9.]+[.][a-zA-Z0-9]+([:][0-9]+)*){1}/;
|
||||
|
||||
export default function isUrlCommand(shell, data) {
|
||||
const matcher = regex[shell]; // eslint-disable-line import/namespace
|
||||
if (undefined === matcher || !data) {
|
||||
|
|
@ -9,22 +7,10 @@ export default function isUrlCommand(shell, data) {
|
|||
}
|
||||
|
||||
const match = data.match(matcher);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
const protocol = match[1];
|
||||
const path = match[2];
|
||||
const urlRegex = /((?:https?:\/\/)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/;
|
||||
|
||||
if (path) {
|
||||
if (protocol) {
|
||||
return `${protocol}${path}`;
|
||||
}
|
||||
// extract the domain portion from the url
|
||||
const domain = path.split('/')[0];
|
||||
if (domainRegex.test(domain)) {
|
||||
const result = path.match(domainRegex)[0];
|
||||
return `http://${result}`;
|
||||
}
|
||||
if (match && urlRegex.test(match[2])) {
|
||||
return `${match[2]}`;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const sh = /(?:ba)?sh: ((?:https?:\/\/)|(?:file:\/\/)|(?:\/\/))?(.*): (?:(?:command not found)|(?:No such file or directory))/;
|
||||
export const sh = /(?:ba)?sh: ((?:file:\/\/)|(?:\/\/))?(.*): (?:(?:command not found)|(?:No such file or directory))/;
|
||||
export const bash = sh;
|
||||
export const zsh = /zsh: (?:(?:command not found)|(?:no such file or directory)): ((?:https?:\/\/)|(?:file:\/\/)|(?:\/\/))?([^\n]+)/;
|
||||
export const fish = /fish: Unknown command '((?:https?:\/\/)|(?:file:\/\/)|(?:\/\/))?([^']+)'/;
|
||||
export const zsh = /zsh: (?:(?:command not found)|(?:no such file or directory)): ((?:file:\/\/)|(?:\/\/))?([^\n]+)/;
|
||||
export const fish = /fish: Unknown command '((?:file:\/\/)|(?:\/\/))?([^']+)'/;
|
||||
|
|
|
|||
Loading…
Reference in a new issue