2019-09-02 16:19:05 +00:00
|
|
|
/*
|
|
|
|
Extract hostname from url
|
|
|
|
url = 'https://open.rocket.chat/method'
|
|
|
|
hostname = 'open.rocket.chat'
|
|
|
|
*/
|
2021-09-13 20:41:05 +00:00
|
|
|
export const extractHostname = url => {
|
2019-09-02 16:19:05 +00:00
|
|
|
let hostname;
|
|
|
|
|
|
|
|
if (url.indexOf('//') > -1) {
|
2021-09-13 20:41:05 +00:00
|
|
|
[, , hostname] = url.split('/');
|
2019-09-02 16:19:05 +00:00
|
|
|
} else {
|
|
|
|
[hostname] = url.split('/');
|
|
|
|
}
|
|
|
|
[hostname] = hostname.split(':');
|
|
|
|
[hostname] = hostname.split('?');
|
|
|
|
|
|
|
|
return hostname;
|
|
|
|
};
|