verdnatura-chat/app/utils/server.js

19 lines
364 B
JavaScript
Raw Normal View History

/*
Extract hostname from url
url = 'https://open.rocket.chat/method'
hostname = 'open.rocket.chat'
*/
export const extractHostname = (url) => {
let hostname;
if (url.indexOf('//') > -1) {
[,, hostname] = url.split('/');
} else {
[hostname] = url.split('/');
}
[hostname] = hostname.split(':');
[hostname] = hostname.split('?');
return hostname;
};