var pathArray = "https://somedomain.com".split( '/' ); var protocol = pathArray[0]; var host = pathArray[2]; var url = protocol + '//' + host;