@Test public void supportUnicodePeriods() { assertEquals("host.com", Authority.split("host。com").host().display()); assertEquals("host.com", Authority.split("host．com").host().display()); assertEquals("host.com", Authority.split("host｡com").host().display()); }
public static Authority split(String authority) { int lastColon = -1; int numColons = 0; int start = authority.length(); int end = authority.length(); int port = -1; while (--start >= 0) { char b = authority.charAt(start); if (b == '@') { break; } else if (b == ':') { if (numColons++ == 0) { lastColon = start; } } } start++; if (start == end || start == lastColon) { throw new IllegalArgumentException("URL missing host. Input: " + authority); } if (numColons == 1) { port = parseAndValidatePort(authority, lastColon); end = lastColon; } else if (numColons > 1) { if (authority.charAt(lastColon - 1) == ']') { port = parseAndValidatePort(authority, lastColon); end = lastColon; } } return new AutoValue_Authority(port, Hosts.parse(authority.substring(start, end))); }
Authority { public static Authority split(String authority) { int lastColon = -1; int numColons = 0; int start = authority.length(); int end = authority.length(); int port = -1; while (--start >= 0) { char b = authority.charAt(start); if (b == '@') { break; } else if (b == ':') { if (numColons++ == 0) { lastColon = start; } } } start++; if (start == end || start == lastColon) { throw new IllegalArgumentException("URL missing host. Input: " + authority); } if (numColons == 1) { port = parseAndValidatePort(authority, lastColon); end = lastColon; } else if (numColons > 1) { if (authority.charAt(lastColon - 1) == ']') { port = parseAndValidatePort(authority, lastColon); end = lastColon; } } return new AutoValue_Authority(port, Hosts.parse(authority.substring(start, end))); } }
Authority { public static Authority split(String authority) { int lastColon = -1; int numColons = 0; int start = authority.length(); int end = authority.length(); int port = -1; while (--start >= 0) { char b = authority.charAt(start); if (b == '@') { break; } else if (b == ':') { if (numColons++ == 0) { lastColon = start; } } } start++; if (start == end || start == lastColon) { throw new IllegalArgumentException("URL missing host. Input: " + authority); } if (numColons == 1) { port = parseAndValidatePort(authority, lastColon); end = lastColon; } else if (numColons > 1) { if (authority.charAt(lastColon - 1) == ']') { port = parseAndValidatePort(authority, lastColon); end = lastColon; } } return new AutoValue_Authority(port, Hosts.parse(authority.substring(start, end))); }  }
Authority { public static Authority split(String authority) { int lastColon = -1; int numColons = 0; int start = authority.length(); int end = authority.length(); int port = -1; while (--start >= 0) { char b = authority.charAt(start); if (b == '@') { break; } else if (b == ':') { if (numColons++ == 0) { lastColon = start; } } } start++; if (start == end || start == lastColon) { throw new IllegalArgumentException("URL missing host. Input: " + authority); } if (numColons == 1) { port = parseAndValidatePort(authority, lastColon); end = lastColon; } else if (numColons > 1) { if (authority.charAt(lastColon - 1) == ']') { port = parseAndValidatePort(authority, lastColon); end = lastColon; } } return new AutoValue_Authority(port, Hosts.parse(authority.substring(start, end))); }  abstract int port(); abstract Host host(); static Authority split(String authority); @Override String toString(); }
Authority { public static Authority split(String authority) { int lastColon = -1; int numColons = 0; int start = authority.length(); int end = authority.length(); int port = -1; while (--start >= 0) { char b = authority.charAt(start); if (b == '@') { break; } else if (b == ':') { if (numColons++ == 0) { lastColon = start; } } } start++; if (start == end || start == lastColon) { throw new IllegalArgumentException("URL missing host. Input: " + authority); } if (numColons == 1) { port = parseAndValidatePort(authority, lastColon); end = lastColon; } else if (numColons > 1) { if (authority.charAt(lastColon - 1) == ']') { port = parseAndValidatePort(authority, lastColon); end = lastColon; } } return new AutoValue_Authority(port, Hosts.parse(authority.substring(start, end))); }  abstract int port(); abstract Host host(); static Authority split(String authority); @Override String toString();  }