diff --git a/lib/actions/sessions.js b/lib/actions/sessions.js index e97dbcea..14630459 100644 --- a/lib/actions/sessions.js +++ b/lib/actions/sessions.js @@ -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({ diff --git a/lib/utils/url-command.js b/lib/utils/url-command.js index 20114399..5af379c8 100644 --- a/lib/utils/url-command.js +++ b/lib/utils/url-command.js @@ -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; diff --git a/lib/utils/url-regex.js b/lib/utils/url-regex.js index 1e9b45d0..0823b309 100644 --- a/lib/utils/url-regex.js +++ b/lib/utils/url-regex.js @@ -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:\/\/)|(?:\/\/))?([^']+)'/;