/** If non-standard port, returns server and post. */ public String getHost(){ if(host==null)return ""; if(isDefaultPort() || 0==port)return host; return host+":"+port; } public String host(){return getHost();}
if(port!=0 && !isDefaultPort()){ builder.append(":"); builder.append(port);
/** http://www.w3.org/TR/url/#concept-url-origin */ public String getOrigin(){ switch(scheme){ case "blob": throw new NotImplementedException(); case "ftp": case "gopher": case "http": case "https": case "ws": case "wss": //https://html.spec.whatwg.org/multipage/browsers.html#unicode-serialisation-of-an-origin //(schema, server, port) String result=scheme + "://" + host; if(!isDefaultPort())result+=":"+port; return result; case "file": throw new NotImplementedException(); default: throw new NotImplementedException(); } } public String origin(){return getOrigin();}