IPV6Util { public static String stripBracketsAndZoneID(String host) { if (host != null && host.length() > 2 && host.contains(":")) { if (host.startsWith("[") && host.endsWith("]")) { host = host.substring(1, host.length() - 1); } if (host.contains("%")) { return host.substring(0, host.indexOf("%")); } } return host; }  static String encloseHost(final String host); static String stripBracketsAndZoneID(String host);  }
@Test public void testStripBracketsAndZoneID() { assertEquals("fd00::d7dc:b4cc:2e2a:ea1", IPV6Util.stripBracketsAndZoneID("[fd00::d7dc:b4cc:2e2a:ea1%enp0s3]")); assertEquals("127.0.0.1", IPV6Util.stripBracketsAndZoneID("127.0.0.1")); }