mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 21:58:39 -09:00
parent
8cc47a498c
commit
6b385036d7
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import * as regex from './url-regex';
|
import * as regex from './url-regex';
|
||||||
|
|
||||||
export const domainRegex = /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b|^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*:)*?:?0*1$/;
|
export const domainRegex = /([0-9]+[:.]*)+|([a-zA-Z0-9.]+[.][a-zA-Z0-9.]+([:][0-9]+)*){1}/;
|
||||||
|
|
||||||
export default function isUrlCommand(shell, data) {
|
export default function isUrlCommand(shell, data) {
|
||||||
const matcher = regex[shell]; // eslint-disable-line import/namespace
|
const matcher = regex[shell]; // eslint-disable-line import/namespace
|
||||||
|
|
@ -22,7 +22,8 @@ export default function isUrlCommand(shell, data) {
|
||||||
// extract the domain portion from the url
|
// extract the domain portion from the url
|
||||||
const domain = path.split('/')[0];
|
const domain = path.split('/')[0];
|
||||||
if (domainRegex.test(domain)) {
|
if (domainRegex.test(domain)) {
|
||||||
return `http://${path}`;
|
const result = path.match(domainRegex)[0];
|
||||||
|
return `http://${result}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue