If you do not need to support Internet Explorer ( http://caniuse.com/#feat=url ), use the URL . Use hostname instead of host .
> new URL("http://TLVS0015:3000/cti/YTest").hostname tlvs0015
Port 80. Port 80 is the default, so it is redundant, hence "" .
> new URL("http://ctmwe:80/ReportServer/ReportService2010.asmx").port "" port = URL.port === "" ? 80 : URL.port
For more information on URL() , refer to the MDN API docs .
Note : As of July 2017, the URL not supported by Internet Explorer 11: http://caniuse.com/#feat=url
source share