2019-09-02 16:19:05 +00:00
|
|
|
/*
|
|
|
|
Extract hostname from url
|
|
|
|
url = 'https://open.rocket.chat/method'
|
|
|
|
hostname = 'open.rocket.chat'
|
|
|
|
*/
|
2022-01-24 20:12:25 +00:00
|
|
|
export const extractHostname = (url: string): string => {
|
2019-09-02 16:19:05 +00:00
|
|
|
let hostname;
|
|
|
|
|
|
|
|
if (url.indexOf('//') > -1) {
|
2021-10-01 18:12:19 +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;
|
|
|
|
};
|