@Test public void testParseService() { Assert.assertEquals( AwsHostNameUtils.parseServiceName(URI.create("https: "s3" ); Assert.assertEquals( AwsHostNameUtils.parseServiceName(URI.create("https: "s3" ); }
public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); if (!host.endsWith(".amazonaws.com") && !host.endsWith(".amazonaws.com.cn")) { return "s3"; } String serviceAndRegion = host.substring(0, host.indexOf(".amazonaws.com")); if (serviceAndRegion.endsWith(".s3") || S3_ENDPOINT_PATTERN.matcher(serviceAndRegion).matches()) { return "s3"; } char separator = '.'; if (serviceAndRegion.indexOf(separator) == -1) { return serviceAndRegion; } return serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); }
AwsHostNameUtils { public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); if (!host.endsWith(".amazonaws.com") && !host.endsWith(".amazonaws.com.cn")) { return "s3"; } String serviceAndRegion = host.substring(0, host.indexOf(".amazonaws.com")); if (serviceAndRegion.endsWith(".s3") || S3_ENDPOINT_PATTERN.matcher(serviceAndRegion).matches()) { return "s3"; } char separator = '.'; if (serviceAndRegion.indexOf(separator) == -1) { return serviceAndRegion; } return serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); } }
AwsHostNameUtils { public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); if (!host.endsWith(".amazonaws.com") && !host.endsWith(".amazonaws.com.cn")) { return "s3"; } String serviceAndRegion = host.substring(0, host.indexOf(".amazonaws.com")); if (serviceAndRegion.endsWith(".s3") || S3_ENDPOINT_PATTERN.matcher(serviceAndRegion).matches()) { return "s3"; } char separator = '.'; if (serviceAndRegion.indexOf(separator) == -1) { return serviceAndRegion; } return serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); }  }
AwsHostNameUtils { public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); if (!host.endsWith(".amazonaws.com") && !host.endsWith(".amazonaws.com.cn")) { return "s3"; } String serviceAndRegion = host.substring(0, host.indexOf(".amazonaws.com")); if (serviceAndRegion.endsWith(".s3") || S3_ENDPOINT_PATTERN.matcher(serviceAndRegion).matches()) { return "s3"; } char separator = '.'; if (serviceAndRegion.indexOf(separator) == -1) { return serviceAndRegion; } return serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); }  static String parseRegionName(final String host, final String serviceHint); static String parseServiceName(URI endpoint); }
AwsHostNameUtils { public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); if (!host.endsWith(".amazonaws.com") && !host.endsWith(".amazonaws.com.cn")) { return "s3"; } String serviceAndRegion = host.substring(0, host.indexOf(".amazonaws.com")); if (serviceAndRegion.endsWith(".s3") || S3_ENDPOINT_PATTERN.matcher(serviceAndRegion).matches()) { return "s3"; } char separator = '.'; if (serviceAndRegion.indexOf(separator) == -1) { return serviceAndRegion; } return serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); }  static String parseRegionName(final String host, final String serviceHint); static String parseServiceName(URI endpoint);  }