mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
18 lines
464 B
JavaScript
18 lines
464 B
JavaScript
import path from 'path';
|
|
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;
|
|
}
|
|
|
|
const match = data.match(matcher);
|
|
const urlRegex = /((?:https?:\/\/)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/;
|
|
|
|
if (match && urlRegex.test(match[2])) {
|
|
return `${match[2]}`;
|
|
}
|
|
|
|
return null;
|
|
}
|