hyper/lib/utils/url-command.js

19 lines
464 B
JavaScript
Raw Normal View History

import path from 'path';
2016-07-13 12:44:24 -08:00
import * as regex from './url-regex';
export default function isUrlCommand(shell, data) {
const matcher = regex[path.parse(shell).name]; // eslint-disable-line import/namespace
if (undefined === matcher || !data) {
return null;
}
2016-07-14 15:40:15 -08:00
const match = data.match(matcher);
const urlRegex = /((?:https?:\/\/)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/;
2016-07-14 15:40:15 -08:00
if (match && urlRegex.test(match[2])) {
return `${match[2]}`;
2016-07-13 12:44:24 -08:00
}
2016-07-14 15:40:15 -08:00
return null;
2016-07-13 12:44:24 -08:00
}