Guillermo Rauch
9 years ago
1 changed files with 17 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||
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'); |
|||
} |
|||
} |
Loading…
Reference in new issue