You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
399 B
18 lines
399 B
9 years ago
|
import { parse } from 'url';
|
||
|
|
||
|
/**
|
||
|
* Converts a valid deployment lookup parameter to a hostname.
|
||
|
* `http://google.com` => google.com
|
||
|
* google.com => google.com
|
||
|
*/
|
||
|
|
||
|
export default function toHost (url) {
|
||
|
if (/^https?:\/\//.test(url)) {
|
||
|
return parse(url).host;
|
||
|
} else {
|
||
|
// remove any path if present
|
||
|
// `a.b.c/` => `a.b.c`
|
||
|
return url.replace(/(\/\/)?([^\/]+)(.*)/, '$2');
|
||
|
}
|
||
|
}
|